mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 09:36:08 +08:00
18 lines
451 B
TypeScript
18 lines
451 B
TypeScript
import { } from 'hydrooj';
|
|
|
|
const { md5, sha1 } = global.Hydro.lib;
|
|
|
|
interface Udoc {
|
|
uname: string,
|
|
unameLower: string,
|
|
}
|
|
|
|
function hash(password: string, salt: string, udoc: 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'] = hash;
|