我看了一下这个问题,并希望自己做.当我运行此代码时(直接从这个答案):
$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";
Run Code Online (Sandbox Code Playgroud)
但是我得到了警告
openssl_encrypt(): Using an empty Initialization Vector (iv) is potentially insecure and not recommended
Run Code Online (Sandbox Code Playgroud)
所以我去看看文档,但没有文档.我发现了这个评论,但仍然没有提到初始化矢量应该是什么以及我应该如何使用它.任何人都可以开导我吗?
我知道我本可以做更多的Google,但Stackoverflow首先出现在如此多的搜索结果中我认为这个问题对于遇到此问题的其他人可能会有用.