Browse Source

Start adding some Javadoc comments.

master
Damien Goutte-Gattat 9 months ago
parent
commit
dd0a445e1e
  1. 19
      src/main/java/org/incenp/sjcl/SJCL.java

19
src/main/java/org/incenp/sjcl/SJCL.java

@ -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;

Loading…
Cancel
Save