且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

为什么 RSA 加密文本给我相同的文本不同的结果

更新时间:2022-12-20 08:20:39

使用适当的填充方案实现了安全的 RSA 加密,其中包括一些随机性.请参阅 PKCS#1OAEP 了解更多详情.

A secure RSA encryption is implemented with an appropriate padding scheme, which includes some randomness. See PKCS#1 or OAEP for more details.

RSA 加密对用0"和一串随机位填充的消息进行加密.在这个过程中,随机字符串通过密码散列和异或隐藏"在密文中.在解密时,RSA 解密从密文中恢复随机字符串并使用它来恢复消息.这就是为什么您使用 openssl rsautl 获得相同文本消息的不同结果的原因.

The RSA encryption encrypts message padded with '0's and and a string of random bit. In the process, the random string is "hidden" in the ciphertext by cryptographic hashing and XORing. On decryption, the RSA decryption recovers the random string from the ciphertext and use it to recover message. This is why you get different result with openssl rsautl for the same text message.