gpt4 book ai didi

c# - AES 加密 key 和 IV

转载 作者:行者123 更新时间:2023-12-04 00:43:31 25 4
gpt4 key购买 nike

我有一个函数可以使用 AES 对用户输入的 key 文本进行加密。并根据要求解密。维护 AES 加密的 key 和 IV 的理想方法是什么(截至目前已在应用程序中硬编码)。我每次都将加密数据保存在数据库中。在页面加载时,从数据库中检索加密值。该值在单击按钮时被解密。有什么我可以更好地使用 key 和 IV 的方法。

最佳答案

IV 可以保存(或者可以甚至公开“公开”/传输);它是 no 'secret' . key 应保密。所以你可以保存/传输你的数据,比如 <iv_here>;<encrypted_data_here> .

参见 wikipedia :

An initialization vector (IV) is a block of bits that is used by several modes to randomize the encryption and hence to produce distinct ciphertexts even if the same plaintext is encrypted multiple times, without the need for a slower re-keying process.

An initialization vector has different security requirements than a key, so the IV usually does not need to be secret. However, in most cases, it is important that an initialization vector is never reused under the same key.

关于c# - AES 加密 key 和 IV,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15633128/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com