-
Notifications
You must be signed in to change notification settings - Fork 6
/
asU8a.ts
28 lines (22 loc) · 849 Bytes
/
asU8a.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import { sha256 as sha256Js } from 'https://esm.sh/@noble/hashes@1.3.0/sha256.js';
import { sha512 as sha512Js } from 'https://esm.sh/@noble/hashes@1.3.0/sha512.js';
import { sha256, sha512 } from 'https://deno.land/x/polkadot@0.2.33/wasm-crypto/mod.ts';
import { createBitHasher, createDualHasher } from '../helpers.ts';
/**
* @name shaAsU8a
* @summary Creates a sha Uint8Array from the input.
*/
export const shaAsU8a = /*#__PURE__*/ createDualHasher(
{ 256: sha256, 512: sha512 },
{ 256: sha256Js, 512: sha512Js }
);
/**
* @name sha256AsU8a
* @summary Creates a sha256 Uint8Array from the input.
*/
export const sha256AsU8a = /*#__PURE__*/ createBitHasher(256, shaAsU8a);
/**
* @name sha512AsU8a
* @summary Creates a sha512 Uint8Array from the input.
*/
export const sha512AsU8a = /*#__PURE__*/ createBitHasher(512, shaAsU8a);