I've successfully encrypted some values using the commented out code below (they've been encrypted only once and look like ENC('asdhsjkdfhlakshlgkj')).
SimplePBEConfig config = new SimplePBEConfig();
config.setKeyObtentionIterations(1000);
config.setPassword("FilePassword");
StandardPBEStringEncryptor encryptor = new org.jasypt.encryption.pbe.StandardPBEStringEncryptor();
encryptor.setConfig(config);
encryptor.initialize();
Properties configFileProperties = readConfigFile();
// for (Object key : configFileProperties.keySet()) {
// if(key.toString().contains("password")) {
// writeToConfigFile(key.toString(), PropertyValueEncryptionUtils.encrypt(configFileProperties.getProperty(key.toString()), encryptor));
// }
// }
System.out.println(PropertyValueEncryptionUtils.decrypt("dev.password", encryptor));
I'm getting the following error:
Exception in thread "main" org.jasypt.exceptions.EncryptionOperationNotPossibleException
at org.jasypt.encryption.pbe.StandardPBEByteEncryptor.decrypt(StandardPBEByteEncryptor.java:918)
at org.jasypt.encryption.pbe.StandardPBEStringEncryptor.decrypt(StandardPBEStringEncryptor.java:725)
at org.jasypt.properties.PropertyValueEncryptionUtils.decrypt(PropertyValueEncryptionUtils.java:72)
at Encrypt.main(Encrypt.java:28)
Following the first answer in this post: https://stackoverflow.com/questions/15544266/org-jasypt-exceptions-encryptionoperationnotpossibleexception#:~:text=EncryptionOperationNotPossibleException%20is%20a%20general%20exception,encrypted%20before%20with%20other%20password
I've added the proper policy files to my JRE following these directions (JAR method as I'm a windows machine without YUM): https://docs.datastax.com/en/cassandra-oss/3.0/cassandra/configuration/installJCE.html
I then restarted my computer just to make sure. Still getting the same error.