public final class Encryption
extends java.lang.Object
Note: The author of this class is by far not a security expert. The chosen implementation has been primarily gathered from examples in the javax.crypto Javadoc and from discussions on StackOverflow.
See also here for a more detailed explanation on the selected security algorithms.
| Constructor and Description |
|---|
Encryption(javax.crypto.Cipher ecipher,
javax.crypto.Cipher dcipher) |
| Modifier and Type | Method and Description |
|---|---|
static Encryption |
createEncryption(char[] passphrase)
Creates a new Encryption instance that uses password-based encryption (PBE).
|
java.lang.String |
decrypt(java.lang.String string)
Decrypts the given text.
|
java.lang.String |
encrypt(java.lang.String string)
Encrypts the given text.
|
public Encryption(javax.crypto.Cipher ecipher,
javax.crypto.Cipher dcipher)
throws java.security.GeneralSecurityException
java.security.GeneralSecurityExceptionpublic java.lang.String encrypt(java.lang.String string)
string - the text to encryptpublic java.lang.String decrypt(java.lang.String string)
string - the text to decryptpublic static Encryption createEncryption(char[] passphrase)
passphrase - the passphrase to apply when creating the secret keyjava.lang.RuntimeException - with wrapped GeneralSecurityException in case of crypto-related exceptions