1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-16 08:13:42 +00:00

stub out crypto function service with pbkdf2

This commit is contained in:
Kyle Spearrin
2018-04-14 23:20:37 -04:00
parent 759ac04ee9
commit 4ad29e25f3
5 changed files with 68 additions and 5 deletions

View File

@@ -0,0 +1,17 @@
import * as crypto from 'crypto';
import { CryptoFunctionService } from '../abstractions/cryptoFunction.service';
export class NodeCryptoFunctionService implements CryptoFunctionService {
async pbkdf2(password: Buffer, salt: Buffer, iterations: number, length: number): Promise<ArrayBuffer> {
return new Promise<ArrayBuffer>((resolve, reject) => {
crypto.pbkdf2(password, salt, iterations, length, 'sha256', (error, key) => {
if (error != null) {
reject(error);
} else {
resolve(key.buffer);
}
});
});
}
}