mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
import without pid check, fix bulk, upgrade dep
This commit is contained in:
1 parent
ac9dc00c6a
commit
76f105c4c8
14 files changed
+117
-193
No files matched your search
@@ -0,0 +1,33 @@
|
||||
import 'hydrooj';
|
||||
import md5 from 'hydrooj/src/lib/md5';
|
||||
import sha1 from 'hydrooj/src/lib/sha1';
|
||||
import pwhash from 'hydrooj/src/lib/hash.hydro';
|
||||
import 'hydrooj/src/utils';
|
||||
|
||||
describe('crypto', () => {
|
||||
const content1 = 'twd2akioi';
|
||||
const content2 = '陈志鹏爱吃玻璃。';
|
||||
|
||||
test('MD5', () => {
|
||||
const result1 = '57b6a9bd92c0502714ecedc4a5ebf24c';
|
||||
const result2 = 'f598cb0738e7cd9efbbdf0ad7b6b42a7';
|
||||
expect(md5(content1)).toStrictEqual(result1);
|
||||
expect(md5(content2)).toStrictEqual(result2);
|
||||
});
|
||||
|
||||
test('SHA1', () => {
|
||||
const result1 = 'bade50df188c338fae183cf3bde34fafaf590bc5';
|
||||
const result2 = '4d3fce39e3a163fe65263d8283ed3e98244fda42';
|
||||
expect(sha1(content1)).toStrictEqual(result1);
|
||||
expect(sha1(content2)).toStrictEqual(result2);
|
||||
});
|
||||
|
||||
test('PWHASH', () => {
|
||||
const password1 = 'password1';
|
||||
const salt1 = '0326Bc23E6fac733K01g29fBBUSAj7O4';
|
||||
const salt2 = String.random(32);
|
||||
const hash1 = '70a2db6a53ecd75d8d4b19d8647a416b4e812c1a6635c4a1f5069a00382fdcb6';
|
||||
expect(pwhash(password1, salt1)).toStrictEqual(hash1);
|
||||
expect(pwhash(password1, salt2)).not.toEqual(hash1);
|
||||
});
|
||||
});
|
||||
@@ -1,14 +0,0 @@
|
||||
import 'hydrooj';
|
||||
import pwhash from 'hydrooj/src/lib/hash.hydro';
|
||||
import 'hydrooj/src/utils';
|
||||
|
||||
describe('Hash', () => {
|
||||
test('server', () => {
|
||||
const password1 = 'password1';
|
||||
const salt1 = '0326Bc23E6fac733K01g29fBBUSAj7O4';
|
||||
const salt2 = String.random(32);
|
||||
const hash1 = '70a2db6a53ecd75d8d4b19d8647a416b4e812c1a6635c4a1f5069a00382fdcb6';
|
||||
expect(pwhash(password1, salt1)).toStrictEqual(hash1);
|
||||
expect(pwhash(password1, salt2)).not.toEqual(hash1);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user