1 import { binaryStringToArray } from '@proton/crypto/lib/utils';
3 import { hashedResult0, hashedResult2, hashedResult4, watResult } from '../test/passwords.data';
4 import '../test/setup';
5 import { releaseCryptoProxy, setupCryptoProxyForTesting } from '../test/setup';
6 import { expandHash, hashPassword } from './passwords';
8 describe('passwords', () => {
9 beforeAll(setupCryptoProxyForTesting);
10 afterAll(releaseCryptoProxy);
12 it('should expand a hash', async () => {
13 const result = await expandHash(binaryStringToArray('wat'));
14 expect(result).toEqual(watResult);
17 it('should hash password version 4', async () => {
18 const hashed = await hashPassword({
22 modulus: new Uint8Array(256),
25 expect(hashed).toEqual(hashedResult4);
28 it('should hash password version 3', async () => {
29 const hashed = await hashPassword({
33 modulus: new Uint8Array(256),
36 expect(hashed).toEqual(hashedResult4);
39 it('should hash password version 2', async () => {
40 const hashed = await hashPassword({
44 modulus: new Uint8Array(256),
47 expect(hashed).toEqual(hashedResult2);
50 it('should hash password version 1', async () => {
51 const hashed = await hashPassword({
55 modulus: new Uint8Array(256),
58 expect(hashed).toEqual(hashedResult2);
61 it('should hash password version 0', async () => {
62 const hashed = await hashPassword({
66 modulus: new Uint8Array(256),
69 expect(hashed).toEqual(hashedResult0);