我看了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
所以我go 看了docs个,但"没有文档".我找到了comment,但仍然没有提到初始化向量应该是什么,以及应该如何使用它.谁能启发我吗?
我知道我可以做更多的谷歌搜索,但是Stackoverflow在这么多搜索结果中排在第一位,我想这个问题可能对其他有这个问题的人很有用.