【发布时间】:2019-10-14 16:35:36
【问题描述】:
我尝试在 Laravel5.7 中加密文件
$encryptedContent = encrypt($fileContent);
用于加密文件。
$decryptedContent = base64_encode(decrypt($encryptedContent));
用于解密。
我的问题是我需要为不同的用户使用不同的密钥来加密文件和解密。 我尝试了以下方式。
$crypt = new \Illuminate\Encryption\Encrypter($newkey);
$encryptedContent = $crypt->encrypt($fileContent);
但它给出了以下错误。
The only supported ciphers are AES-128-CBC and AES-256-CBC with the correct key lengths
谁能帮帮我? 谢谢。
【问题讨论】:
-
密钥是 128 位还是 256 位长?
-
是的。应用密钥是 base64:zy1fG2idaKNqNI7JWaolANWS5hJuxTfsaDvGFFfZxj4= 像这样。