简体   繁体   English

如何在两个不同的平台上使用相同的加密密钥?

[英]How do I use the same encryption key on two different platforms?

I am working on a project where the user would access the server and send commands to the server. 我正在一个项目中,用户可以访问服务器并将命令发送到服务器。 The server would then send the information / results back. 然后,服务器将信息/结果发回。 The commands that are sent to the server, and the information received from the server, will be encrypted in AES 128. 发送到服务器的命令以及从服务器接收的信息将在AES 128中加密。

The AES key will be made from the password. AES密钥将从密码中获取。 The password can be any length, so the key would be derived from the password. 密码可以是任何长度,因此密钥将从密码中派生。 An IV and salt will also be generated. 还会产生IV和盐。

The only problem that I have is that the IV, salt and key is different each time on the server and on the client. 我唯一的问题是服务器,客户端上的IV,salt和key每次都不同。 How can I ensure that the keys are the same so that I can successfully encrypt and decrypt my data on both sides? 如何确保密钥相同,以便可以成功地对双方的数据进行加密和解密?

The salt and the IV have to be shared before the encryption starts. 加密开始之前必须共享salt和IV。

They don't need to be kept secret, but they should be generated fresh for every session. 他们不需要保密,但是应该为每个会话重新生成它们。

The derived AES key will be the same if salt and (shared secret) password are the same on both ends. 如果salt和(共享密钥)密码的两端相同,则派生的AES密钥将相同。

The IV can be chosen by the encrypting party and transmitted (in the clear) before the encrypted data. IV可以由加密方选择,并在加密数据之前(以明文形式)传输。 That way the recipient can initialize AES for encryption. 这样,接收者可以初始化AES进行加密。

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

相关问题 在不同平台上进行相同的哈希+加密会生成不同的值 - Same hashing + encryption in different platforms generating unidentical values 如何在两个不同的方法中使用相同的变量而不使这些变量成为全局变量? - How do I use same variable inside two different methods without making those variables global? 如何使用onTouchListener从同一按钮执行两项不同的任务 - How to use an onTouchListener to do two different tasks from the same button 我是否同时在2个不同的StreamTask中使用相同的键值存储(RockDB)? - Do I use the same key-value storage (RockDBs) in 2 different StreamTask same time? 我可以在两个不同的listView中使用相同的ArrayAdapter吗? 怎么样? - Can I use the same ArrayAdapter in two different listViews? How? 如何保护我的 Java AES 加密密钥 - How do I protect my Java AES encryption key Java程序在不同平台上以相同的速度执行吗? - Do java programs execute in different platforms with the same speed? 如何在不同的Java项目中使用相同的方法 - How do I use same method in different Java projects 我如何对FXML中的不同按钮使用同一事件 - How do I use the same event for different buttons in FXML 如何在同一活动中使用两个不同的OnClickListener? - how to use two different OnClickListener in same activity?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM