gpt4 book ai didi

encryption - 如何在 AES 加密中用随机数解密

转载 作者:行者123 更新时间:2023-12-04 14:37:28 25 4
gpt4 key购买 nike

我是密码学的新手。我需要使用具有某些配置的 AES 加密文本

Encryption mode: GCM
Key size: 256 bits
Nonce size: 96 bits
MAC size: 128 bits

由于 AES 是一种对称算法。所以我有一个 secret key 。我用谷歌搜索并发现

nonce is a random number used to make sure a message is unique



但我有疑问,如果 nonce 是随机数,我该如何进行解密。我是否需要将随机数与每个加密一起存储。或者我需要使用 key 拆分 nonce、cipher 和 mac 的任何其他方式。
我如何使用提供的配置进行加密。

最佳答案

But i have a doubt, how i can perform decryption, if nonce is a random number. do i need to store nonce along with each encryption.


是的,存储/发送的加密结果是随机数、密文、mac。

how i can perform decryption, if nonce is a random number


加密输入时随机生成随机数,然后随机数随密文传递(通常随机数作为第一个块被添加)。实际上,解密时您需要相同的随机数值,然后随机数是解密输入的一部分,而不是随机数

or any other way i need to split nonce, cipher and mac using key. how can i use the provided configuration for encryption.


有一个 standardized message format用于加密文档或 encrypted XML messages ,但这些都相当复杂。
实际上 - 对于更简单的应用程序,我们经常看到加密输出组成为 IV || ciphertext || MAC (作为串联)。 IV和MAC是固定长度的,可以剪下来用参数解密。

decryption is happening on different machine and language. they have shared only a key for encryption. same key they are using for decryption. if i will add any random value as nonce then how hey will know what logic i have used for nonc


在您提供相同的输入之前,这并不重要。如前所述 - 您可以将 IV(随机数)作为消息的一部分传递,并在解密之前将随机数和原始密文分开。
顺便说一句:我有 a few encryption examples链接

关于encryption - 如何在 AES 加密中用随机数解密,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59029634/

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