/** * Creates a new instance that will use the given passphrase for all encryption/decryption activities. * * @param passphrase the passphrase to encrypt/decrypt the credentials with * @return the new instance */ public static CredentialsEncryptor withPassphrase(char[] passphrase) { Encryption encryption = Encryption.createEncryption(passphrase); return new CredentialsEncryptor(encryption); }
/** * Creates a new instance that will use the given passphrase for all encryption/decryption activities. * * @param passphrase the passphrase to encrypt/decrypt the credentials with * @return the new instance */ public static CredentialsEncryptor withPassphrase(char[] passphrase) { Encryption encryption = Encryption.createEncryption(passphrase); return new CredentialsEncryptor(encryption); }
@Test public void encryptDecryptAcrossDifferentEncryptionInstances() { char[] passphrase = "My very secret pass phrase".toCharArray(); String textToEncrypt = "Some text that needs to be encrypted."; Encryption encryption = Encryption.createEncryption(passphrase); String encrypted = encryption.encrypt(textToEncrypt); Encryption encryption2 = Encryption.createEncryption(passphrase); String decrypted = encryption2.decrypt(encrypted); assertEquals(textToEncrypt, decrypted); }