All files / utils hashing.ts

91.67% Statements 11/12
50% Branches 1/2
100% Functions 4/4
91.67% Lines 11/12

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 281x 1x 1x 1x   1x 1x     1x 4x 4x             4x     4x            
const iterations = 25000;
const keylen = 100;
const digest = "sha512";
const crypto = require("crypto");
 
export function generateSalt() {
    return crypto.randomBytes(16).toString("hex");
}
 
export function hashPassword(salt: string, password: string) {
    return new Promise<string>((resolve, reject) => {
        crypto.pbkdf2(
            password,
            salt,
            iterations,
            keylen,
            digest,
            (err: Object, key: Buffer) => {
                Iif (err) {
                    reject(err);
                } else {
                    resolve(key.toString("hex"));
                }
            },
        );
    });
}