【发布时间】:2018-02-19 23:33:43
【问题描述】:
BytesEncryptor enc = Encryptors.standard("encryptionPassword",saltKey);
byte[] encryptedPwd = enc.encrypt(pwd.getBytes());
byte[] decryptedPwd = enc.decrypt(encryptedPwd );
我使用 BytesEncryptors (Spring security) 来加密/解密密码。我在字节 [] 中有我的加密/解密密码。我想得到加密/解密的密码。
所以我要做的是,
System.out.println(new String(encryptedPwd,"UTF-8"));
System.out.println(new String(decryptedPwd,"UTF-8"));
第二行运行良好。第一行没有给我编码密码的字符串表示形式。它显示了一些无用的东西。
1) 为什么我的第一行不像第二行那样工作?
2) 如果我想对我的 spring bean 配置(XML 文件)使用相同的加密算法,我会怎么做?像 DataSource Info/其他一些登录凭据应该在 XML 文件中加密。(* 我在这里不使用 Hibernate)
【问题讨论】:
-
尝试使用
Ctrl+'K'或 ' ` ' 引号格式化您的代码 -
您希望加密后的密码是什么样的?
-
我得到这样的东西'–Ú×°ä÷q“ýd。而且我不确定它是否是存储在属性文件中的加密密码
标签: java spring encryption spring-security aes