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:
17
src/services/nodeCryptoFunction.service.ts
Normal file
17
src/services/nodeCryptoFunction.service.ts
Normal 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);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user