|
Jasypt Users Forum
Unable to decrypt encrypted passwords in property files using EncryptablePropertyPlaceholderConfigurer
Hallo list,
I was realy happy to find such a nice framework that promises easy to use encryption features.
Now I'm somewhat frustrated because my sinple scenario does not work and I can't see my fault.
The Scene:
- The command line tool to encrypt a password
- A properties file with the encrypted Passwort
- a spring configuration that uses the EncryptablePropertyPlaceholderConfigurer to replace the passwordPlaceholder with the decrypted password
The porblem:
decryption allways failes with an Exception: javax.crypto.BadPaddingException: Given final block not properly padded
The configuration:
- Windows XP,
- Java 1.6.12 with Unlimited Strength Java(TM) Cryptography Extension Policy Files
- Jasyp 1.5
- Spring configuration:
<!-- use encrypted passwords in config files -->
<bean id="propertyConfigurer" class="org.jasypt.spring.properties.EncryptablePropertyPlaceholderConfigurer">
<constructor-arg ref="strongEncryptor"/>
<property name="location" value="classpath:degewo.properties"/>
</bean>
<bean id="strongEncryptor" class="org.jasypt.encryption.pbe.StandardPBEStringEncryptor">
<property name="algorithm" value="PBEWithMD5AndTripleDES"/>
<property name="password" value="this-is-a-very-long-and-quiet-easy-to-guess-password-4-me!"/>
<property name="saltGenerator" ref="nullGenerator"/>
</bean>
<bean id="nullGenerator" class="org.jasypt.salt.ZeroSaltGenerator"/>
I tries with the default SaltGenerator (Random I suppose) before but with same result.
The encrypted password has been generated with the CLI (encrypt input=toBeEncrypted password=somePwdContaining-4!), copied the result from the command line window and pasted it into the properties file. At this stage i did not specify a SaltGenerator in my Spring configuration eg. using default.
Than I created a test case in my IDE (Idea 8), copied the code from org.jasypt.intf.cli.JasyptPBEStringDecryptionCLI, defined the ZeroSaltGenerator (for encryption as well as for decryption) and got the encrypted String in the IDE window. I copied and pasted it into the properties file and watched the decryption failing as before.
On debuging I did't see anything strange, the byte[] on encryption and decryption (at all stages: base64 - encryption) had the same length...
Well, plese shed some light on this. Where is the error? How to do this correctly? It appears to be so damned simple!
Thanks a lot
Bubenik
|