Showing
1 changed file
with
5 additions
and
5 deletions
@@ -9,7 +9,7 @@ namespace Plugin; | @@ -9,7 +9,7 @@ namespace Plugin; | ||
9 | class Encryption { | 9 | class Encryption { |
10 | 10 | ||
11 | //密钥 | 11 | //密钥 |
12 | - private static $_secrect_key = 'yoho9646abcdefgh'; | 12 | + private static $_secretKey = 'yoho9646abcdefgh'; |
13 | 13 | ||
14 | /** | 14 | /** |
15 | * 加密方法 | 15 | * 加密方法 |
@@ -20,11 +20,11 @@ class Encryption { | @@ -20,11 +20,11 @@ class Encryption { | ||
20 | public static function encrypt($str, $key = ''){ | 20 | public static function encrypt($str, $key = ''){ |
21 | 21 | ||
22 | //AES, 128 ECB模式加密数据 | 22 | //AES, 128 ECB模式加密数据 |
23 | - $screct_key = $key ? $key : self::$_secrect_key; | 23 | + $secretKey = $key ? $key : self::$_secretKey; |
24 | $str = trim($str); | 24 | $str = trim($str); |
25 | // $str = self::addPKCS7Padding($str); | 25 | // $str = self::addPKCS7Padding($str); |
26 | $iv = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128,MCRYPT_MODE_ECB),MCRYPT_RAND); | 26 | $iv = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128,MCRYPT_MODE_ECB),MCRYPT_RAND); |
27 | - $encrypt_str = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $screct_key, $str, MCRYPT_MODE_ECB, $iv); | 27 | + $encrypt_str = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $secretKey, $str, MCRYPT_MODE_ECB, $iv); |
28 | return base64_encode($encrypt_str); | 28 | return base64_encode($encrypt_str); |
29 | } | 29 | } |
30 | 30 | ||
@@ -36,10 +36,10 @@ class Encryption { | @@ -36,10 +36,10 @@ class Encryption { | ||
36 | */ | 36 | */ |
37 | public static function decrypt($str, $key = ''){ | 37 | public static function decrypt($str, $key = ''){ |
38 | //AES, 128 ECB模式加密数据 | 38 | //AES, 128 ECB模式加密数据 |
39 | - $screct_key = $key ? $key : self::$_secrect_key; | 39 | + $secretKey = $key ? $key : self::$_secretKey; |
40 | $str = base64_decode($str); | 40 | $str = base64_decode($str); |
41 | $iv = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128,MCRYPT_MODE_ECB),MCRYPT_RAND); | 41 | $iv = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128,MCRYPT_MODE_ECB),MCRYPT_RAND); |
42 | - $encrypt_str = mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $screct_key, $str, MCRYPT_MODE_ECB, $iv); | 42 | + $encrypt_str = mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $secretKey, $str, MCRYPT_MODE_ECB, $iv); |
43 | $encrypt_str = trim($encrypt_str); | 43 | $encrypt_str = trim($encrypt_str); |
44 | // $encrypt_str = self::stripPKSC7Padding($encrypt_str); | 44 | // $encrypt_str = self::stripPKSC7Padding($encrypt_str); |
45 | return $encrypt_str; | 45 | return $encrypt_str; |
-
Please register or login to post a comment