Skip to content
This repository was archived by the owner on Feb 7, 2023. It is now read-only.

Commit e293477

Browse files
committed
Bring back convenience function hash.bytes()
1 parent e37ffaf commit e293477

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

src/hash/sha1/sha1.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,8 @@ export class Sha1 extends Hash<sha1result> {
1313
protected static heap_pool = [];
1414
protected static asm_pool = [];
1515
protected static asm_function = sha1_asm;
16+
17+
static bytes(data: Uint8Array): Uint8Array {
18+
return new Sha1().process(data).finish().result;
19+
}
1620
}

src/hash/sha256/sha256.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,8 @@ export class Sha256 extends Hash<sha256result> {
1313
protected static heap_pool = [];
1414
protected static asm_pool = [];
1515
protected static asm_function = sha256_asm;
16+
17+
static bytes(data: Uint8Array): Uint8Array {
18+
return new Sha256().process(data).finish().result;
19+
}
1620
}

src/hash/sha512/sha512.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,8 @@ export class Sha512 extends Hash<sha512result> {
1313
protected static heap_pool = [];
1414
protected static asm_pool = [];
1515
protected static asm_function = sha512_asm;
16+
17+
static bytes(data: Uint8Array): Uint8Array {
18+
return new Sha512().process(data).finish().result;
19+
}
1620
}

0 commit comments

Comments
 (0)