简体   繁体   English

AES加密(Python和Java)

[英]AES Encryption (Python and Java)

I'm making a project in Java and Python that includes sending an encrypted string from one to the other. 我正在用Java和Python制作一个项目,包括从一个到另一个发送加密的字符串。 I can get the languages to understand each other and fully de-crypt / encrypt strings. 我可以让语言相互理解并完全解密/加密字符串。 However I was talking to somebody and was told that I am not being totally secure. 然而,我正在和某人说话,并被告知我并不完全安全。 I am using AES encryption for the project. 我正在为项目使用AES加密。 Part of the problem is that I am distributing the software and need to come up with an effective way and secure way of making sure both the server side know the IV and 'Secret Key' . 部分问题在于我正在分发软件,需要提出一种有效的方法和安全的方法来确保服务器端都知道IV'密钥' Right now the same string will always encrypt to be the same result. 现在,相同的字符串将始终加密为相同的结果。 If I could change those two factors they would be different, so 2 users with the same password won't have the same encrypted password. 如果我可以改变这两个因素,那么它们将是不同的,因此具有相同密码的2个用户将不具有相同的加密密码。 Please do keep in mind that the server only needs to manage one account. 请记住,服务器只需要管理一个帐户。

I appreciate your responses, and thank you very much ahead of time! 感谢您的回复,并提前感谢您!

Typically, you'd generate the IV randomly, and send it along with the encrypted message. 通常,您会随机生成IV,并将其与加密消息一起发送。 The IV doesn't need to be secret--it just needs to be different for every message you send. IV不需要保密 - 它只需要为您发送的每条消息都有所不同。

There are a wide variety of concerns to worry about when implementing crypto. 在实施加密时需要担心各种各样的问题。 Your block cipher mode matters, for instance--if you're using an IV you probably aren't using ECB, but that leaves quite a few other options open. 例如,你的分组密码模式很重要 - 如果你使用的是IV,你可能没有使用ECB,但这会留下很多其他选项。 Padding attacks and other subtle things are also a concern. 填充攻击和其他微妙的事情也是一个问题。

Generally, you don't want to implement crypto yourself if you can possibly avoid it. 通常,如果您可以避免加密,您不希望自己实施加密。 It's much too easy to get wrong, and usually quite important to get right. 这很容易出错,而且通常非常重要。 You may want to ask for more help on the Security StackExchange. 您可能想要在Security StackExchange上寻求更多帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM