1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-18 01:03:35 +00:00

test pbkdf2 node function

This commit is contained in:
Kyle Spearrin
2018-04-25 16:30:47 -04:00
parent 33c3af3a8e
commit e7735f2d80
2 changed files with 52 additions and 2 deletions

View File

@@ -9,11 +9,11 @@ import { Utils } from '../misc/utils';
export class NodeCryptoFunctionService implements CryptoFunctionService {
pbkdf2(password: string | ArrayBuffer, salt: string | ArrayBuffer, algorithm: 'sha256' | 'sha512',
iterations: number): Promise<ArrayBuffer> {
const len = algorithm === 'sha256' ? 256 : 512;
const len = algorithm === 'sha256' ? 32 : 64;
const nodePassword = this.toNodeValue(password);
const nodeSalt = this.toNodeValue(salt);
return new Promise<ArrayBuffer>((resolve, reject) => {
crypto.pbkdf2(nodePassword, nodeSalt, iterations, length, algorithm, (error, key) => {
crypto.pbkdf2(nodePassword, nodeSalt, iterations, len, algorithm, (error, key) => {
if (error != null) {
reject(error);
} else {