Toggle navigation
Toggle navigation
This project
Loading...
Sign in
fe
/
YOHOBUYWAP
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
0
Merge Requests
0
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Email Patches
Plain Diff
Browse Files
Authored by
周少峰
9 years ago
Commit
d17a2bbdfd10f2590ac8216005fdcaac6a6e6638
1 parent
df31b7e6
modify encryption
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
5 deletions
library/Plugin/Encryption.php
library/Plugin/Encryption.php
View file @
d17a2bb
...
...
@@ -9,7 +9,7 @@ namespace Plugin;
class
Encryption
{
//密钥
private
static
$_secre
ct_k
ey
=
'yoho9646abcdefgh'
;
private
static
$_secre
tK
ey
=
'yoho9646abcdefgh'
;
/**
* 加密方法
...
...
@@ -20,11 +20,11 @@ class Encryption {
public
static
function
encrypt
(
$str
,
$key
=
''
){
//AES, 128 ECB模式加密数据
$s
crect_key
=
$key
?
$key
:
self
::
$_secrect_k
ey
;
$s
ecretKey
=
$key
?
$key
:
self
::
$_secretK
ey
;
$str
=
trim
(
$str
);
// $str = self::addPKCS7Padding($str);
$iv
=
mcrypt_create_iv
(
mcrypt_get_iv_size
(
MCRYPT_RIJNDAEL_128
,
MCRYPT_MODE_ECB
),
MCRYPT_RAND
);
$encrypt_str
=
mcrypt_encrypt
(
MCRYPT_RIJNDAEL_128
,
$s
crect_k
ey
,
$str
,
MCRYPT_MODE_ECB
,
$iv
);
$encrypt_str
=
mcrypt_encrypt
(
MCRYPT_RIJNDAEL_128
,
$s
ecretK
ey
,
$str
,
MCRYPT_MODE_ECB
,
$iv
);
return
base64_encode
(
$encrypt_str
);
}
...
...
@@ -36,10 +36,10 @@ class Encryption {
*/
public
static
function
decrypt
(
$str
,
$key
=
''
){
//AES, 128 ECB模式加密数据
$s
crect_key
=
$key
?
$key
:
self
::
$_secrect_k
ey
;
$s
ecretKey
=
$key
?
$key
:
self
::
$_secretK
ey
;
$str
=
base64_decode
(
$str
);
$iv
=
mcrypt_create_iv
(
mcrypt_get_iv_size
(
MCRYPT_RIJNDAEL_128
,
MCRYPT_MODE_ECB
),
MCRYPT_RAND
);
$encrypt_str
=
mcrypt_decrypt
(
MCRYPT_RIJNDAEL_128
,
$s
crect_k
ey
,
$str
,
MCRYPT_MODE_ECB
,
$iv
);
$encrypt_str
=
mcrypt_decrypt
(
MCRYPT_RIJNDAEL_128
,
$s
ecretK
ey
,
$str
,
MCRYPT_MODE_ECB
,
$iv
);
$encrypt_str
=
trim
(
$encrypt_str
);
// $encrypt_str = self::stripPKSC7Padding($encrypt_str);
return
$encrypt_str
;
...
...
Please
register
or
login
to post a comment