summaryrefslogtreecommitdiffhomepage
path: root/packages/server/src/helpers/toHash.ts
diff options
context:
space:
mode:
authorMatthew Miller <matthew@millerti.me>2022-11-11 19:47:02 -0800
committerMatthew Miller <matthew@millerti.me>2022-11-11 19:47:08 -0800
commita42cd6ab88bc3081e86a10d920c5a3949ee48f95 (patch)
treeace1e1dbc9e2253a75465b59f7e141ab69aecafa /packages/server/src/helpers/toHash.ts
parentb258acf84eedd5eefdecbe70baaeefe004ad6111 (diff)
Make toHash async to prep for SubtleCrypto
Diffstat (limited to 'packages/server/src/helpers/toHash.ts')
-rw-r--r--packages/server/src/helpers/toHash.ts5
1 files changed, 4 insertions, 1 deletions
diff --git a/packages/server/src/helpers/toHash.ts b/packages/server/src/helpers/toHash.ts
index e599a4d..413e96f 100644
--- a/packages/server/src/helpers/toHash.ts
+++ b/packages/server/src/helpers/toHash.ts
@@ -5,6 +5,9 @@ import crypto from 'crypto';
* @param data Data to hash
* @return The hash
*/
-export function toHash(data: Uint8Array | string, algo = 'SHA256'): Uint8Array {
+// TODO: Made this async in preparation for trying to use globalThis.crypto (SubtleCrypto) to
+// hash values, which returns a Promise
+// https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/digest
+export async function toHash(data: Uint8Array | string, algo = 'SHA256'): Promise<Uint8Array> {
return crypto.createHash(algo).update(data).digest();
}