Closed pinux-studio closed 6 years ago
Jasypt simply doesn't work with that algorithm the way its internal encryptor is setting cipher params:
/*
* Perform decryption using the Cipher
*/
final PBEParameterSpec parameterSpec =
new PBEParameterSpec(salt, this.keyObtentionIterations);
synchronized (this.decryptCipher) {
this.decryptCipher.init(
Cipher.DECRYPT_MODE, this.key, parameterSpec);
decryptedMessage =
this.decryptCipher.doFinal(encryptedMessageKernel);
}
Yo can use SimplePBEByteEncryptor in conjunction with SimplePBEStringEncryptor that I just added to master. That encryptor actually supports the algorithm you wanted to use. You can use it like this:
@Bean("jasyptStringEncryptor")
public StringEncryptor stringEncryptor() {
SimplePBEByteEncryptor encryptor = new SimplePBEByteEncryptor();
encryptor.setPassword("some password loco");
encryptor.setSaltGenerator(new RandomSaltGenerator());
encryptor.setIterations(1000);
encryptor.setAlgorithm("PBEWITHHMACSHA512ANDAES_256");
SimplePBEStringEncryptor stringEncryptor = new SimplePBEStringEncryptor(encryptor);
return stringEncryptor;
}
Bear in mind though, this encryptors are not yet part of jasypt-spring-boot
so you'd have to copy the classes into your project.
I have to encrypt DB password using SHA2 PBEWITHHMACSHA512ANDAES_256 algorithm, but unable to decrypt it in Spring 4 application with JPA. On decryption, its throwing EncryptionOperationNotPossibleException.
Your project is really awesome and I like the document you have done. However, I fail to find the way to use customised algo such as PBEWITHHMACSHA512ANDAES_256 in my project.
My setup looks like:
then I get the error
Caused by: com.ulisesbocchio.jasyptspringboot.exception.DecryptionException: Decryption of Properties failed, make sure encryption/decryption passwords match