migrate-hustoj: fix password check

This commit is contained in:
undefined committed 2021-11-30 23:10:15 +08:00
1 parent 11cc42b943
commit 0934f79cfc
4 files changed
+6 -6

No files matched your search

+2 -2
View File
@@ -5,8 +5,8 @@ const RE_MD5 = /^[\da-f]{32}$/;
function hash($password: string, $saved: string) {
$password = md5($password);
if (RE_MD5.test($saved)) return $password === $saved;
const $svd = Buffer.from($saved, 'base64').toString();
const $salt = $svd.substr(20);
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),