Showing
1 changed file
with
5 additions
and
5 deletions
@@ -8,7 +8,7 @@ namespace WebPlugin; | @@ -8,7 +8,7 @@ namespace WebPlugin; | ||
8 | class Encryption { | 8 | class Encryption { |
9 | 9 | ||
10 | //密钥 | 10 | //密钥 |
11 | - private static $_secrect_key = 'yoho9646abcdefgh'; | 11 | + private static $_secretKey = 'yoho9646abcdefgh'; |
12 | 12 | ||
13 | //前面补8位0 | 13 | //前面补8位0 |
14 | private static $_preString = '00000000'; | 14 | private static $_preString = '00000000'; |
@@ -21,11 +21,11 @@ class Encryption { | @@ -21,11 +21,11 @@ class Encryption { | ||
21 | public static function encrypt($str){ | 21 | public static function encrypt($str){ |
22 | $str = self::$_preString.$str; | 22 | $str = self::$_preString.$str; |
23 | //AES, 128 ECB模式加密数据 | 23 | //AES, 128 ECB模式加密数据 |
24 | - $screct_key = self::$_secrect_key; | 24 | + $secretKey = self::$_secretKey; |
25 | $str = trim($str); | 25 | $str = trim($str); |
26 | $str = self::addPKCS7Padding($str); | 26 | $str = self::addPKCS7Padding($str); |
27 | $iv = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128,MCRYPT_MODE_ECB),MCRYPT_RAND); | 27 | $iv = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128,MCRYPT_MODE_ECB),MCRYPT_RAND); |
28 | - $encrypt_str = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $screct_key, $str, MCRYPT_MODE_ECB, $iv); | 28 | + $encrypt_str = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $secretKey, $str, MCRYPT_MODE_ECB, $iv); |
29 | return base64_encode($encrypt_str); | 29 | return base64_encode($encrypt_str); |
30 | } | 30 | } |
31 | 31 | ||
@@ -36,10 +36,10 @@ class Encryption { | @@ -36,10 +36,10 @@ class Encryption { | ||
36 | */ | 36 | */ |
37 | public static function decrypt($str){ | 37 | public static function decrypt($str){ |
38 | //AES, 128 ECB模式加密数据 | 38 | //AES, 128 ECB模式加密数据 |
39 | - $screct_key = self::$_secrect_key; | 39 | + $secretKey = 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 | $encrypt_str = ltrim($encrypt_str, self::$_preString); | 45 | $encrypt_str = ltrim($encrypt_str, self::$_preString); |
-
Please register or login to post a comment