mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
优化rating计算速度
This commit is contained in:
1 parent
45f1184d68
commit
55912b087d
22 files changed
+309
-178
No files matched your search
@@ -0,0 +1,23 @@
|
||||
|
||||
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}`;
|
||||
},
|
||||
};
|
||||
Reference in new issue
Block a user