draft: 从hustoj导入数据

This commit is contained in:
undefined committed 2020-09-26 20:15:27 +08:00
1 parent aa93512298
commit 21c2bb95f0
11 files changed
+168 -153

No files matched your search

+12
View File
@@ -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;