Java AES加密与盐 [英] Java AES Encryption with salt
问题描述
如何使Java加密
String message1 =hello world;
与 String salt =mySalt;
使用AES加密?加密后如何解密? 如果你有时间提供最基本的代码,那将会帮助我很多。 b
还有一个关于AES加密的一般问题,使用相同的盐,相同的消息总是具有相同的加密?
提前感谢。
AES没有盐的概念。它只需要数据和一个键。对于相同的输入,它将始终生成相同的输出。
如何将您的消息与盐结合在一起取决于您。字符串连接可能就足够了。但请注意,盐对于像AES这样的东西来说并不太有意义,因为它不是散列算法。
Alright, turns out I suck at Encryption/Decryption. I just dont get it.
How can I make Java encrypt String message1 = "hello world";
with String salt = "mySalt";
using AES encryption? also how can I decrypt it once encrypted?
If you have the time to provide the most basic code, it would help me a lot.
Also 1 general question about AES encryption, using the same salt, will the same message always have the same encryption?
Thanks in advance.
AES doesn't have a concept of a salt. It just takes data, and a key. For the same input, it will always generate the same output.
How you combine your message with your salt is up to you. String concatenation is probably sufficient. But note that salts don't really make a lot of sense for something like AES, because it's not a hash algorithm.
这篇关于Java AES加密与盐的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!