1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-18 09:13:33 +00:00

AuditService (#2)

* Add AuditService.

* Change sha1 to use Webcrypto.

* Add interface for AuditService.

* Move PwnedPasswodsApi constant outside class.

* Change FromBufferToHex implementation to simpler code.

* Use correct string to array function.

* Change auditService interface to abstract class. Add missing type to utils.
This commit is contained in:
Oscar Hinton
2018-02-28 16:52:35 +01:00
committed by Kyle Spearrin
parent ab00dfd399
commit 1aabb42e47
5 changed files with 49 additions and 0 deletions

View File

@@ -452,6 +452,17 @@ export class CryptoService implements CryptoServiceAbstraction {
return b64DecValue;
}
async sha1(password: string): Promise<string> {
const hash = await Crypto.subtle.digest(
{
name: 'SHA-1',
},
UtilsService.fromUtf8ToArray(password),
);
return UtilsService.fromBufferToHex(hash);
}
// Helpers
private async aesEncrypt(plainValue: ArrayBuffer, key: SymmetricCryptoKey): Promise<EncryptedObject> {