Skip to content

Commit

Permalink
修复AES256报错问题
Browse files Browse the repository at this point in the history
  • Loading branch information
Yurunsoft committed May 23, 2019
1 parent 8ceef75 commit 7e7a1f2
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/Lib/Encrypt/AES.php
Original file line number Diff line number Diff line change
Expand Up @@ -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')));
}
}

0 comments on commit 7e7a1f2

Please sign in to comment.