问题描述
我已经使用下面注释掉的代码成功加密了一些值(它们只加密了一次,看起来像 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
然后我重新启动了我的电脑只是为了确定。仍然出现同样的错误。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)