aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared/core-utils/crypto.ts
diff options
context:
space:
mode:
Diffstat (limited to 'shared/core-utils/crypto.ts')
-rw-r--r--shared/core-utils/crypto.ts14
1 files changed, 14 insertions, 0 deletions
diff --git a/shared/core-utils/crypto.ts b/shared/core-utils/crypto.ts
new file mode 100644
index 000000000..d6d1150d0
--- /dev/null
+++ b/shared/core-utils/crypto.ts
@@ -0,0 +1,14 @@
1import { BinaryToTextEncoding, createHash } from 'crypto'
2
3function sha256 (str: string | Buffer, encoding: BinaryToTextEncoding = 'hex') {
4 return createHash('sha256').update(str).digest(encoding)
5}
6
7function sha1 (str: string | Buffer, encoding: BinaryToTextEncoding = 'hex') {
8 return createHash('sha1').update(str).digest(encoding)
9}
10
11export {
12 sha256,
13 sha1
14}