mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
加载过程优化
This commit is contained in:
1 parent
bc6426927f
commit
5db23edebb
8 files changed
+74
-58
No files matched your search
@@ -1,22 +1,10 @@
|
||||
const { md5, sha1 } = global.Hydro.lib;
|
||||
|
||||
global.Hydro.lib['hash.vj2'] = module.exports = {
|
||||
/**
|
||||
* @param {string} password
|
||||
* @param {string} salt
|
||||
* @param {string} hash
|
||||
*/
|
||||
check(password, salt, hash, udoc) {
|
||||
return hash === this.hash(password, salt, udoc);
|
||||
},
|
||||
/**
|
||||
* @param {string} password
|
||||
* @param {string} salt
|
||||
*/
|
||||
hash(password, salt, udoc) {
|
||||
const { uname, unameLower } = udoc;
|
||||
const pmd5 = md5(password);
|
||||
const mixedSha1 = sha1(md5(unameLower + pmd5) + salt + sha1(pmd5 + salt));
|
||||
return `${Buffer.from(uname).toString('base64')}|${mixedSha1}`;
|
||||
},
|
||||
};
|
||||
function hash(password, salt, udoc) {
|
||||
const { uname, unameLower } = udoc;
|
||||
const pmd5 = md5(password);
|
||||
const mixedSha1 = sha1(md5(unameLower + pmd5) + salt + sha1(pmd5 + salt));
|
||||
return `${Buffer.from(uname).toString('base64')}|${mixedSha1}`;
|
||||
}
|
||||
|
||||
global.Hydro.lib['hash.vj2'] = module.exports = hash;
|
||||
Reference in new issue
Block a user