1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-12-27 17:18:04 +01:00

formatting cleanup

This commit is contained in:
Kyle Spearrin 2018-02-28 11:09:10 -05:00
parent e1041e9b5b
commit e3b3e444db
2 changed files with 5 additions and 12 deletions

View File

@ -453,13 +453,8 @@ export class CryptoService implements CryptoServiceAbstraction {
}
async sha1(password: string): Promise<string> {
const hash = await Crypto.subtle.digest(
{
name: 'SHA-1',
},
UtilsService.fromUtf8ToArray(password),
);
const passwordArr = UtilsService.fromUtf8ToArray(password);
const hash = await Crypto.subtle.digest({ name: 'SHA-1' }, passwordArr);
return UtilsService.fromBufferToHex(hash);
}

View File

@ -125,12 +125,10 @@ export class UtilsService implements UtilsServiceAbstraction {
return decodeURIComponent(escape(encodedString));
}
// Source: Frxstrem, https://stackoverflow.com/questions/40031688/javascript-arraybuffer-to-hex
// ref: https://stackoverflow.com/a/40031979/1090359
static fromBufferToHex(buffer: ArrayBuffer): string {
return Array.prototype.map.call(
new Uint8Array(buffer),
(x: number) => ('00' + x.toString(16)).slice(-2),
).join('');
const bytes = new Uint8Array(buffer);
return Array.prototype.map.call(bytes, (x: number) => ('00' + x.toString(16)).slice(-2)).join('');
}
static getHostname(uriString: string): string {