作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想知道我是否可以在 AES 加密中加密两个或多个字符串。比方说,我想加密用户名、密码和 nonce_value。我可以使用以下代码吗?
try {
String codeWord = username, password, nonceInString;
String encryptedData = aseEncryptDecrypt.encrypt(codeWord);
String decryptedData = aseEncryptDecrypt.decrypt(encryptedData);
System.out.println("Encrypted : " + encryptedData);
System.out.println("Decrypted : " + decryptedData);
} catch (Throwable e) {
e.printStackTrace();
}
最佳答案
那行得通吗?为什么不试试那个代码看看呢?从理论上讲,您当然可以将多条数据放在一个字符串中并加密该字符串,尽管您需要一种更好的方法将数据放在一起。您当前的代码(在用户名、密码和 nonceInString 之间使用逗号)将无法编译,但如果您可以防止冒号存在于任何这些字符串中,您可以执行以下操作:
String codeWord = username+":"+password+":"+nonceInString;
然后当您解码时,只需在冒号处拆分即可。
关于java - 如何在 AES 加密中加密/解密多个字符串?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2734310/
我是一名优秀的程序员,十分优秀!