首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >初始化向量在openssl_encrypt中的使用

初始化向量在openssl_encrypt中的使用
EN

Stack Overflow用户
提问于 2012-08-06 08:06:18
回答 1查看 61.8K关注 0票数 79

我看了一下this的问题,想为自己做一件事。当我运行这段代码(直接取自this answer)时:

$textToEncrypt = "My super secret information.";
$encryptionMethod = "AES-256-CBC";  // AES is used by the U.S. gov't to encrypt top secret documents.
$secretHash = "25c6c7ff35b9979b151f2136cd13b0ff";

//To encrypt
$encryptedMessage = openssl_encrypt($textToEncrypt, $encryptionMethod, $secretHash, '1234567812345678');

//To Decrypt
$decryptedMessage = openssl_decrypt($encryptedMessage, $encryptionMethod, $secretHash);

//Result
echo "Encrypted: $encryptedMessage <br>Decrypted: $decryptedMessage";

但是我得到了警告

openssl_encrypt(): Using an empty Initialization Vector (iv) is potentially insecure and not recommended

所以我去看了一下docs,但是“没有文档”。我找到了这个comment,但仍然没有提到初始化向量应该是什么以及我应该如何使用它。有谁能开导我吗?

我知道我可以做更多的谷歌搜索,但是Stackoverflow在如此多的搜索结果中排在第一位,我想这个问题可能对其他有这个问题的人有用。

EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/11821195

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档