有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java Jasypt无法解密:org。贾斯普特。例外情况。加密操作不可能例外

我已经使用下面注释掉的代码成功地加密了一些值(它们只加密了一次,看起来像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));

我得到以下错误:

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)

下面是这篇文章的第一个答案:https://stackoverflow.com/questions/15544266/org-jasypt-exceptions-encryptionoperationnotpossibleexception#:~:text=EncryptionOperationNotPossibleException%20is%20a%20general%20exception,encrypted%20before%20with%20other%20password

我已经按照以下说明向JRE中添加了适当的策略文件(JAR方法,因为我是一台没有YUM的windows机器):https://docs.datastax.com/en/cassandra-oss/3.0/cassandra/configuration/installJCE.html

然后我重新启动了我的电脑,只是为了确认一下。仍然得到相同的错误


共 (0) 个答案