Java AES加密与盐 [英] Java AES Encryption with salt

查看:2451
本文介绍了Java AES加密与盐的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好吧,原来我吮吸加密/解密。我只是没有得到它。
如何使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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆