java - Jasypt 无法解密:org.jasypt.exceptions.EncryptionOperationNotPossibleException
问题描述
我已经使用下面注释掉的代码成功加密了一些值(它们只加密了一次,看起来像 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)
我已按照以下说明将正确的策略文件添加到我的 JRE(JAR 方法,因为我是没有 YUM 的 Windows 机器):https ://docs.datastax.com/en/cassandra-oss/3.0/cassandra/configuration/安装JCE.html
然后我重新启动我的电脑只是为了确保。仍然得到同样的错误。
解决方案
推荐阅读
- r - 如何计算同一区域不同分类的层堆栈中最丰富的像素值(多数票)?
- mysql - 如何将具有相同PK的项目中的数据添加在一起
- visual-studio-code - 如何返回在 VScode 中打开的上一个选项卡
- google-cloud-data-fusion - java.lang.NoSuchMethodError:net.jpountz.lz4.LZ4BlockInputStream。
(Ljava/io/InputStream;Z)V 预览 - google-sheets - 如何在 Google 表格的查询中选择命名范围?
- boto - Boto 仅删除 100 个 SNS 主题条目,而不是全部
- python-3.x - 根据名称列表命名 DataFrame
- sql - 如何按顺序查询不同表的数据
- autodesk-viewer - 上色后如何恢复原色?
- jquery - 将加/减按钮添加到购物车并根据 AJAX 请求进行更新