From 7e7a1f24fe1628668f62ff5ff879fa0b7f8621fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=87=E6=B6=A6?= Date: Thu, 23 May 2019 15:48:32 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DAES256=E6=8A=A5=E9=94=99?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Lib/Encrypt/AES.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Lib/Encrypt/AES.php b/src/Lib/Encrypt/AES.php index 46e93d4..17119f4 100644 --- a/src/Lib/Encrypt/AES.php +++ b/src/Lib/Encrypt/AES.php @@ -5,21 +5,21 @@ class AES extends Base { public static function encrypt($data, $key) { - return openssl_encrypt($data, 'AES-128-CBC', $key, 0, \str_repeat(chr(0), 16)); + return openssl_encrypt($data, 'AES-128-CBC', $key, 0, \str_repeat(chr(0), openssl_cipher_iv_length('AES-128-CBC'))); } public static function decrypt($data, $key) { - return openssl_decrypt($data, 'AES-128-CBC', $key, 0, \str_repeat(chr(0), 16)); + return openssl_decrypt($data, 'AES-128-CBC', $key, 0, \str_repeat(chr(0), openssl_cipher_iv_length('AES-128-CBC'))); } public static function encrypt256($data, $key) { - return openssl_encrypt($data, 'AES-256-ECB', $key, 0, \str_repeat(chr(0), 32)); + return openssl_encrypt($data, 'AES-256-ECB', $key, 0, \str_repeat(chr(0), openssl_cipher_iv_length('AES-256-ECB'))); } public static function decrypt256($data, $key) { - return openssl_decrypt($data, 'AES-256-ECB', $key, 0, \str_repeat(chr(0), 32)); + return openssl_decrypt($data, 'AES-256-ECB', $key, 0, \str_repeat(chr(0), openssl_cipher_iv_length('AES-256-ECB'))); } } \ No newline at end of file