Start adding some Javadoc comments.

This commit is contained in:
Damien Goutte-Gattat 2021-02-23 22:36:05 +00:00
parent 4948a24435
commit dd0a445e1e
1 changed files with 19 additions and 0 deletions

View File

@ -39,6 +39,15 @@ import org.json.JSONObject;
public class SJCL {
/**
* Encrypts data with default parameters and the specified password.
*
* @param password the password to derive the encryption key from
* @param cleartext the data to encrypt
* @return the encrypted data, as a Base64-encoded JSON structure
* @throws SJCLException if some algorithms are not supported, which should not
* happen
*/
public static String encrypt(String password, String cleartext) throws SJCLException {
byte[] salt = new byte[8];
byte[] iv = new byte[16];
@ -84,6 +93,16 @@ public class SJCL {
return new String(encoder.encode(result.toString().getBytes()));
}
/**
* Decrypts data with the specified password.
*
* @param password the password to derive the decryption key from
* @param ciphertext the encrypted data, as a Base64-encoded JSON structure
* @return the decrypted data
* @throws SJCLException if an algorithm is not supported, if there is any
* problem with the provided ciphertext, or if the
* password is incorrect
*/
public static String decrypt(String password, String ciphertext) throws SJCLException {
Decoder decoder = Base64.getDecoder();
JSONObject json;