mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
w: merge migration packages
This commit is contained in:
1 parent
b5e312b609
commit
74f4e44f0f
12 files changed
+28
-64
No files matched your search
@@ -0,0 +1,23 @@
|
||||
import { md5, sha1 } from 'hydrooj/src/lib/crypto';
|
||||
|
||||
const RE_MD5 = /^[\da-f]{32}$/;
|
||||
|
||||
global.Hydro.lib['hash.hust'] = ($password: string, $saved: string) => {
|
||||
$password = md5($password);
|
||||
if (RE_MD5.test($saved)) return $password === $saved;
|
||||
const $svd = Buffer.from($saved, 'base64').toString('hex');
|
||||
const $salt = Buffer.from($svd.substr(40), 'hex').toString();
|
||||
const $hash = Buffer.concat([
|
||||
Buffer.from(sha1($password + $salt), 'hex'),
|
||||
Buffer.from($salt),
|
||||
]).toString('base64');
|
||||
if ($hash.trim() === $saved.trim()) return true;
|
||||
return false;
|
||||
};
|
||||
|
||||
global.Hydro.lib['hash.vj2'] = (password: string, salt: string, udoc: { uname: string; unameLower: string }) => {
|
||||
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