From e293477003b707cf6cfe8e9dcf2fb9827ea6bc65 Mon Sep 17 00:00:00 2001 From: Daniel Huigens Date: Mon, 2 Jul 2018 16:24:14 +0200 Subject: [PATCH] Bring back convenience function hash.bytes() --- src/hash/sha1/sha1.ts | 4 ++++ src/hash/sha256/sha256.ts | 4 ++++ src/hash/sha512/sha512.ts | 4 ++++ 3 files changed, 12 insertions(+) diff --git a/src/hash/sha1/sha1.ts b/src/hash/sha1/sha1.ts index 33c2f95..f9895ad 100644 --- a/src/hash/sha1/sha1.ts +++ b/src/hash/sha1/sha1.ts @@ -13,4 +13,8 @@ export class Sha1 extends Hash { protected static heap_pool = []; protected static asm_pool = []; protected static asm_function = sha1_asm; + + static bytes(data: Uint8Array): Uint8Array { + return new Sha1().process(data).finish().result; + } } diff --git a/src/hash/sha256/sha256.ts b/src/hash/sha256/sha256.ts index 32b9adb..fc85f77 100644 --- a/src/hash/sha256/sha256.ts +++ b/src/hash/sha256/sha256.ts @@ -13,4 +13,8 @@ export class Sha256 extends Hash { protected static heap_pool = []; protected static asm_pool = []; protected static asm_function = sha256_asm; + + static bytes(data: Uint8Array): Uint8Array { + return new Sha256().process(data).finish().result; + } } diff --git a/src/hash/sha512/sha512.ts b/src/hash/sha512/sha512.ts index 0c2191e..e2c1e45 100644 --- a/src/hash/sha512/sha512.ts +++ b/src/hash/sha512/sha512.ts @@ -13,4 +13,8 @@ export class Sha512 extends Hash { protected static heap_pool = []; protected static asm_pool = []; protected static asm_function = sha512_asm; + + static bytes(data: Uint8Array): Uint8Array { + return new Sha512().process(data).finish().result; + } }