mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
draft: 从hustoj导入数据
This commit is contained in:
1 parent
aa93512298
commit
21c2bb95f0
11 files changed
+168
-153
No files matched your search
@@ -0,0 +1,12 @@
|
||||
import { } from 'hydrooj';
|
||||
|
||||
const { md5, sha1 } = global.Hydro.lib;
|
||||
const RE_MD5 = /^[\da-fA-F]{32}$/;
|
||||
|
||||
function hash(password: string, stored: string) {
|
||||
if (RE_MD5.test(stored)) return md5(password) === stored;
|
||||
const salt = Buffer.from(stored, 'base64').toString().substr(0, 20);
|
||||
return Buffer.from(sha1(password + salt).substr(0, 20) + salt).toString('base64') === stored;
|
||||
}
|
||||
|
||||
global.Hydro.lib['hash.hust'] = hash;
|
||||
Reference in new issue
Block a user