diff options
author | Matthew Miller <matthew@millerti.me> | 2020-05-18 17:23:54 -0700 |
---|---|---|
committer | Matthew Miller <matthew@millerti.me> | 2020-05-18 17:23:54 -0700 |
commit | b9a6310ec7ff4f94501a2c6a72b6cf773ca66762 (patch) | |
tree | 25bd990a69de0238628c3cdef659633653bd3db8 /src | |
parent | 48c3acd1fa288fe2d7670e6babed6448a6bb5351 (diff) |
Create toHash helper
Diffstat (limited to 'src')
-rw-r--r-- | src/helpers/toHash.ts | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/helpers/toHash.ts b/src/helpers/toHash.ts new file mode 100644 index 0000000..6e8db1d --- /dev/null +++ b/src/helpers/toHash.ts @@ -0,0 +1,10 @@ +import crypto from 'crypto'; + +/** + * Returns hash digest of the given data using the given algorithm. + * @param data Data to hash + * @return The hash + */ +export default function toHash(data: Buffer, algo: string = 'SHA256'): Buffer { + return crypto.createHash(algo).update(data).digest(); +} |