Toggle navigation
Toggle navigation
This project
Loading...
Sign in
fe
/
yohobuywap-node
·
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
311a69b4f7e541590e2068dc2886de5e16242103
1 parent
52e42454
uid cookie 加密解密
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
48 deletions
apps/passport/models/aes-pwd.js
package.json
apps/passport/models/aes-pwd.js
View file @
311a69b
...
...
@@ -6,65 +6,23 @@
'use strict'
;
const
crypto
=
require
(
'crypto'
);
const
algorithm
=
'aes-128-ecb'
;
const
clearEncoding
=
'utf8'
;
const
cipherEncoding
=
'base64'
;
const
iv
=
''
;
// 加密
const
_encryption
=
(
keys
,
Keyword
)
=>
{
let
key
=
keys
?
keys
:
'yoho9646abcdefgh'
;
let
cipher
=
crypto
.
createCipheriv
(
algorithm
,
key
,
iv
);
let
cipherChunks
=
[];
cipherChunks
.
push
(
cipher
.
update
(
Keyword
,
clearEncoding
,
cipherEncoding
));
cipherChunks
.
push
(
cipher
.
final
(
cipherEncoding
));
return
cipherChunks
.
join
(
''
);
};
// 解密
const
_decrypt
=
(
keys
,
Keyword
)
=>
{
let
key
=
keys
?
keys
:
'yoho9646abcdefgh'
;
let
decipher
=
crypto
.
createDecipheriv
(
algorithm
,
key
,
iv
);
let
plainChunks
=
[];
let
cipherChunks
=
[
Keyword
];
for
(
let
i
=
0
;
i
<
cipherChunks
.
length
;
i
++
)
{
plainChunks
.
push
(
decipher
.
update
(
cipherChunks
[
i
],
cipherEncoding
,
clearEncoding
));
}
plainChunks
.
push
(
decipher
.
final
(
clearEncoding
));
return
plainChunks
.
join
(
''
);
};
const
crypto
=
global
.
yoho
.
crypto
;
/**
*
登录
密码加密
* 密码加密
**/
const
aesPwd
=
(
pwd
)
=>
{
return
_
encryption
(
'yoho9646yoho9646'
,
pwd
);
return
crypto
.
encryption
(
'yoho9646yoho9646'
,
pwd
);
};
/**
* uid加密
**/
const
encryptionUid
=
(
uid
)
=>
{
return
_
encryption
(
'yoho9646abcdefgh'
,
uid
+
''
);
return
crypto
.
encryption
(
'yoho9646abcdefgh'
,
uid
+
''
);
};
/**
* uid解密
**/
const
DecryptUid
=
(
uid
)
=>
{
return
_decrypt
(
'yoho9646abcdefgh'
,
uid
+
''
);
};
module
.
exports
=
{
aesPwd
,
encryptionUid
,
DecryptUid
encryptionUid
};
...
...
package.json
View file @
311a69b
...
...
@@ -56,7 +56,7 @@
"uuid"
:
"^2.0.2"
,
"winston"
:
"^2.2.0"
,
"winston-daily-rotate-file"
:
"^1.1.4"
,
"yoho-node-lib"
:
"0.0.2
1
"
"yoho-node-lib"
:
"0.0.2
2
"
},
"devDependencies"
:
{
"autoprefixer"
:
"^6.3.6"
,
...
...
Please
register
or
login
to post a comment