0

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.

Paul Sender
  • 90
  • 10
  • The code is not executable. If I modify it to be executable, I can't reproduce the issue. You should post an example with concrete test data and describe your environment including Java and Jasypt version. – Topaco May 30 '21 at 08:13

0 Answers0