@rasmx/hash 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +22 -0
- package/README.md +36 -0
- package/index.d.ts +106 -0
- package/index.js +140 -0
- package/package.json +37 -0
- package/pkg/rasmx_hash.d.ts +323 -0
- package/pkg/rasmx_hash.js +1312 -0
- package/pkg/rasmx_hash_bg.wasm +0 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright © 2026
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
of this software and associated documentation files (the “Software”), to deal
|
|
8
|
+
in the Software without restriction, including without limitation the rights
|
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
furnished to do so, subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in
|
|
14
|
+
all copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
22
|
+
THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# @rasmx/hash 🚀
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@rasmx/hash)
|
|
4
|
+
[](https://opensource.org/licenses/MIT)
|
|
5
|
+
[](https://bundlephobia.com/package/@rasmx/hash)
|
|
6
|
+
|
|
7
|
+
**@rasmx/hash** is a high-performance, universal hashing library for JavaScript and TypeScript, powered by **WebAssembly** and **Rust**.
|
|
8
|
+
|
|
9
|
+
## Why @rasmx/hash?
|
|
10
|
+
|
|
11
|
+
- **Blazing Fast**: Up to 10-20x faster than pure JS implementations (like crypto-js).
|
|
12
|
+
- **Streaming Ready**: Hash gigabytes of data with zero-copy using browser `ReadableStream`.
|
|
13
|
+
- **All-in-One**: One tiny package replaces dozens of single-algorithm libraries.
|
|
14
|
+
- **Modern**: Full support for `SharedArrayBuffer` and ES Modules.
|
|
15
|
+
|
|
16
|
+
## Supported Algorithms
|
|
17
|
+
|
|
18
|
+
| Family | Variants |
|
|
19
|
+
| :--- | :--- |
|
|
20
|
+
| **SHA2** | 224, 256, 384, 512, 512/224, 512/256 |
|
|
21
|
+
| **SHA3** | 224, 256, 384, 512 |
|
|
22
|
+
| **Keccak** | 224, 256, 384, 512 |
|
|
23
|
+
| **XXHash** | 32, 64, 3-64, 3-128 (with Seed support) |
|
|
24
|
+
| **Other** | MD5, HMAC-SHA256, HMAC-SHA512, SHAKE128/256 |
|
|
25
|
+
|
|
26
|
+
## Quick Start
|
|
27
|
+
|
|
28
|
+
```javascript
|
|
29
|
+
import { hash } from '@rasmx/hash';
|
|
30
|
+
|
|
31
|
+
// Simple usage
|
|
32
|
+
const hex = await hash.sha2.v256("hello world");
|
|
33
|
+
|
|
34
|
+
// Streaming large files (Browser)
|
|
35
|
+
const result = await hash.stream(file.stream(), new IncrementalSha256());
|
|
36
|
+
```
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
export type InputData = string | Uint8Array | ArrayBuffer | SharedArrayBuffer;
|
|
2
|
+
|
|
3
|
+
export interface HashFamily {
|
|
4
|
+
v224: (d: InputData) => Promise<string>;
|
|
5
|
+
v256: (d: InputData) => Promise<string>;
|
|
6
|
+
v384: (d: InputData) => Promise<string>;
|
|
7
|
+
v512: (d: InputData) => Promise<string>;
|
|
8
|
+
v512_224: (d: InputData) => Promise<string>;
|
|
9
|
+
v512_256: (d: InputData) => Promise<string>;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const hash: {
|
|
13
|
+
sha2: HashFamily;
|
|
14
|
+
sha3: HashFamily;
|
|
15
|
+
keccak: HashFamily;
|
|
16
|
+
blake3: (d: InputData, key?: InputData) => Promise<string>;
|
|
17
|
+
shake: {
|
|
18
|
+
v128: (d: InputData, len: number) => Promise<string>;
|
|
19
|
+
v256: (d: InputData, len: number) => Promise<string>;
|
|
20
|
+
};
|
|
21
|
+
xxh: {
|
|
22
|
+
v32: (d: InputData, seed?: number) => Promise<string>;
|
|
23
|
+
v64: (d: InputData, seed?: bigint) => Promise<string>;
|
|
24
|
+
v3_64: (d: InputData) => Promise<string>;
|
|
25
|
+
v3_64_seed: (d: InputData, seed: bigint) => Promise<string>;
|
|
26
|
+
v3_128: (d: InputData) => Promise<string>;
|
|
27
|
+
v3_128_seed: (d: InputData, seed: bigint) => Promise<string>;
|
|
28
|
+
};
|
|
29
|
+
hmac: {
|
|
30
|
+
sha256: (key: InputData, d: InputData) => Promise<string>;
|
|
31
|
+
sha512: (key: InputData, d: InputData) => Promise<string>;
|
|
32
|
+
};
|
|
33
|
+
md5: (d: InputData) => Promise<string>;
|
|
34
|
+
stream: (readable: ReadableStream, hasher: any) => Promise<string>;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export interface IHasher {
|
|
38
|
+
update(d: InputData): Promise<void>;
|
|
39
|
+
finalize(): Promise<string>;
|
|
40
|
+
free(): Promise<void>;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export class IncrementalSha256 implements IHasher {
|
|
44
|
+
constructor();
|
|
45
|
+
update(d: InputData): Promise<void>;
|
|
46
|
+
finalize(): Promise<string>;
|
|
47
|
+
free(): Promise<void>;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export class IncrementalSha512 implements IHasher {
|
|
51
|
+
constructor();
|
|
52
|
+
update(d: InputData): Promise<void>;
|
|
53
|
+
finalize(): Promise<string>;
|
|
54
|
+
free(): Promise<void>;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export class IncrementalMd5 implements IHasher {
|
|
58
|
+
constructor();
|
|
59
|
+
update(d: InputData): Promise<void>;
|
|
60
|
+
finalize(): Promise<string>;
|
|
61
|
+
free(): Promise<void>;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export class IncrementalBlake3 implements IHasher {
|
|
65
|
+
constructor();
|
|
66
|
+
update(d: InputData): Promise<void>;
|
|
67
|
+
finalize(): Promise<string>;
|
|
68
|
+
free(): Promise<void>;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export class IncrementalXxh3 {
|
|
72
|
+
constructor();
|
|
73
|
+
update(d: InputData): Promise<void>;
|
|
74
|
+
finalize64(): Promise<string>;
|
|
75
|
+
finalize128(): Promise<string>;
|
|
76
|
+
finalize(): Promise<string>;
|
|
77
|
+
free(): Promise<void>;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export class IncrementalXxh32 implements IHasher {
|
|
81
|
+
constructor(seed?: number);
|
|
82
|
+
update(d: InputData): Promise<void>;
|
|
83
|
+
finalize(): Promise<string>;
|
|
84
|
+
free(): Promise<void>;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export class IncrementalXxh64 implements IHasher {
|
|
88
|
+
constructor(seed?: bigint);
|
|
89
|
+
update(d: InputData): Promise<void>;
|
|
90
|
+
finalize(): Promise<string>;
|
|
91
|
+
free(): Promise<void>;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export class IncrementalSha3_256 implements IHasher {
|
|
95
|
+
constructor();
|
|
96
|
+
update(d: InputData): Promise<void>;
|
|
97
|
+
finalize(): Promise<string>;
|
|
98
|
+
free(): Promise<void>;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export class IncrementalKeccak256 implements IHasher {
|
|
102
|
+
constructor();
|
|
103
|
+
update(d: InputData): Promise<void>;
|
|
104
|
+
finalize(): Promise<string>;
|
|
105
|
+
free(): Promise<void>;
|
|
106
|
+
}
|
package/index.js
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import init, * as wasm from './pkg/rasmx_hash.js';
|
|
2
|
+
|
|
3
|
+
let ready = false;
|
|
4
|
+
async function ensure() {
|
|
5
|
+
if (!ready) {
|
|
6
|
+
await init();
|
|
7
|
+
ready = true;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function toBuf(data) {
|
|
12
|
+
if (data instanceof Uint8Array) return data;
|
|
13
|
+
if (typeof data === 'string') return new TextEncoder().encode(data);
|
|
14
|
+
if (data instanceof ArrayBuffer || (typeof SharedArrayBuffer !== 'undefined' && data instanceof SharedArrayBuffer)) {
|
|
15
|
+
return new Uint8Array(data);
|
|
16
|
+
}
|
|
17
|
+
return new Uint8Array(data);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export const hash = {
|
|
21
|
+
sha2: {
|
|
22
|
+
v224: async (d) => { await ensure(); return wasm.sha2_224(toBuf(d)); },
|
|
23
|
+
v256: async (d) => { await ensure(); return wasm.sha2_256(toBuf(d)); },
|
|
24
|
+
v384: async (d) => { await ensure(); return wasm.sha2_384(toBuf(d)); },
|
|
25
|
+
v512: async (d) => { await ensure(); return wasm.sha2_512(toBuf(d)); },
|
|
26
|
+
v512_224: async (d) => { await ensure(); return wasm.sha2_512_224(toBuf(d)); },
|
|
27
|
+
v512_256: async (d) => { await ensure(); return wasm.sha2_512_256(toBuf(d)); }
|
|
28
|
+
},
|
|
29
|
+
sha3: {
|
|
30
|
+
v224: async (d) => { await ensure(); return wasm.sha3_224(toBuf(d)); },
|
|
31
|
+
v256: async (d) => { await ensure(); return wasm.sha3_256(toBuf(d)); },
|
|
32
|
+
v384: async (d) => { await ensure(); return wasm.sha3_384(toBuf(d)); },
|
|
33
|
+
v512: async (d) => { await ensure(); return wasm.sha3_512(toBuf(d)); }
|
|
34
|
+
},
|
|
35
|
+
keccak: {
|
|
36
|
+
v224: async (d) => { await ensure(); return wasm.keccak_224(toBuf(d)); },
|
|
37
|
+
v256: async (d) => { await ensure(); return wasm.keccak_256(toBuf(d)); },
|
|
38
|
+
v384: async (d) => { await ensure(); return wasm.keccak_384(toBuf(d)); },
|
|
39
|
+
v512: async (d) => { await ensure(); return wasm.keccak_512(toBuf(d)); }
|
|
40
|
+
},
|
|
41
|
+
shake: {
|
|
42
|
+
v128: async (d, len) => { await ensure(); return wasm.shake128(toBuf(d), len); },
|
|
43
|
+
v256: async (d, len) => { await ensure(); return wasm.shake256(toBuf(d), len); }
|
|
44
|
+
},
|
|
45
|
+
blake3: async (d, key = null) => {
|
|
46
|
+
await ensure();
|
|
47
|
+
return key ? wasm.blake3_keyed_hex(toBuf(d), toBuf(key)) : wasm.blake3_hex(toBuf(d));
|
|
48
|
+
},
|
|
49
|
+
xxh: {
|
|
50
|
+
v32: async (d, seed = 0) => { await ensure(); return wasm.xxh32_hex(toBuf(d), seed); },
|
|
51
|
+
v64: async (d, seed = 0n) => { await ensure(); return wasm.xxh64_hex(toBuf(d), BigInt(seed)); },
|
|
52
|
+
v3_64: async (d) => { await ensure(); return wasm.xxh3_64_hex(toBuf(d)); },
|
|
53
|
+
v3_64_seed: async (d, seed) => { await ensure(); return wasm.xxh3_64_seed_hex(toBuf(d), BigInt(seed)); },
|
|
54
|
+
v3_128: async (d) => { await ensure(); return wasm.xxh3_128_hex(toBuf(d)); },
|
|
55
|
+
v3_128_seed: async (d, seed) => { await ensure(); return wasm.xxh3_128_seed_hex(toBuf(d), BigInt(seed)); }
|
|
56
|
+
},
|
|
57
|
+
hmac: {
|
|
58
|
+
sha256: async (key, d) => { await ensure(); return wasm.hmac_sha256(toBuf(key), toBuf(d)); },
|
|
59
|
+
sha512: async (key, d) => { await ensure(); return wasm.hmac_sha512(toBuf(key), toBuf(d)); }
|
|
60
|
+
},
|
|
61
|
+
md5: async (d) => { await ensure(); return wasm.md5_hex(toBuf(d)); },
|
|
62
|
+
stream: async (readable, hasher) => {
|
|
63
|
+
const reader = readable.getReader();
|
|
64
|
+
while (true) {
|
|
65
|
+
const { done, value } = await reader.read();
|
|
66
|
+
if (done) break;
|
|
67
|
+
await hasher.update(value);
|
|
68
|
+
}
|
|
69
|
+
const res = await hasher.finalize();
|
|
70
|
+
if (hasher.free) await hasher.free();
|
|
71
|
+
return res;
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
class BaseIncremental {
|
|
76
|
+
constructor() { this.p = ensure(); this.i = null; }
|
|
77
|
+
async free() {
|
|
78
|
+
await this.p;
|
|
79
|
+
if (this.i) {
|
|
80
|
+
this.i.free();
|
|
81
|
+
this.i = null;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export class IncrementalSha256 extends BaseIncremental {
|
|
87
|
+
constructor() { super(); this.p = this.p.then(() => this.i = new wasm.IncrementalSha256()); }
|
|
88
|
+
async update(d) { await this.p; this.i.update(toBuf(d)); }
|
|
89
|
+
async finalize() { await this.p; return this.i.finalize(); }
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export class IncrementalSha512 extends BaseIncremental {
|
|
93
|
+
constructor() { super(); this.p = this.p.then(() => this.i = new wasm.IncrementalSha512()); }
|
|
94
|
+
async update(d) { await this.p; this.i.update(toBuf(d)); }
|
|
95
|
+
async finalize() { await this.p; return this.i.finalize(); }
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export class IncrementalSha3_256 extends BaseIncremental {
|
|
99
|
+
constructor() { super(); this.p = this.p.then(() => this.i = new wasm.IncrementalSha3_256()); }
|
|
100
|
+
async update(d) { await this.p; this.i.update(toBuf(d)); }
|
|
101
|
+
async finalize() { await this.p; return this.i.finalize(); }
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export class IncrementalKeccak256 extends BaseIncremental {
|
|
105
|
+
constructor() { super(); this.p = this.p.then(() => this.i = new wasm.IncrementalKeccak256()); }
|
|
106
|
+
async update(d) { await this.p; this.i.update(toBuf(d)); }
|
|
107
|
+
async finalize() { await this.p; return this.i.finalize(); }
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export class IncrementalMd5 extends BaseIncremental {
|
|
111
|
+
constructor() { super(); this.p = this.p.then(() => this.i = new wasm.IncrementalMd5()); }
|
|
112
|
+
async update(d) { await this.p; this.i.update(toBuf(d)); }
|
|
113
|
+
async finalize() { await this.p; return this.i.finalize(); }
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export class IncrementalBlake3 extends BaseIncremental {
|
|
117
|
+
constructor() { super(); this.p = this.p.then(() => this.i = new wasm.IncrementalBlake3()); }
|
|
118
|
+
async update(d) { await this.p; this.i.update(toBuf(d)); }
|
|
119
|
+
async finalize() { await this.p; return this.i.finalize(); }
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export class IncrementalXxh3 extends BaseIncremental {
|
|
123
|
+
constructor() { super(); this.p = this.p.then(() => this.i = new wasm.IncrementalXxh3()); }
|
|
124
|
+
async update(d) { await this.p; this.i.update(toBuf(d)); }
|
|
125
|
+
async finalize64() { await this.p; return this.i.finalize_64(); }
|
|
126
|
+
async finalize128() { await this.p; return this.i.finalize_128(); }
|
|
127
|
+
async finalize() { return this.finalize64(); }
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export class IncrementalXxh32 extends BaseIncremental {
|
|
131
|
+
constructor(seed = 0) { super(); this.p = this.p.then(() => this.i = new wasm.IncrementalXxh32(seed)); }
|
|
132
|
+
async update(d) { await this.p; this.i.update(toBuf(d)); }
|
|
133
|
+
async finalize() { await this.p; return this.i.finalize(); }
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
export class IncrementalXxh64 extends BaseIncremental {
|
|
137
|
+
constructor(seed = 0n) { super(); this.p = this.p.then(() => this.i = new wasm.IncrementalXxh64(BigInt(seed))); }
|
|
138
|
+
async update(d) { await this.p; this.i.update(toBuf(d)); }
|
|
139
|
+
async finalize() { await this.p; return this.i.finalize(); }
|
|
140
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@rasmx/hash",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Blazing fast WASM hashing library powered by Rust. Support for SHA2, SHA3, Keccak, XXHash, and MD5 with streaming support.",
|
|
5
|
+
"publishConfig": {
|
|
6
|
+
"access": "public"
|
|
7
|
+
},
|
|
8
|
+
"keywords": [
|
|
9
|
+
"wasm",
|
|
10
|
+
"hash",
|
|
11
|
+
"sha256",
|
|
12
|
+
"sha3",
|
|
13
|
+
"xxhash",
|
|
14
|
+
"keccak",
|
|
15
|
+
"rust",
|
|
16
|
+
"performance",
|
|
17
|
+
"streaming"
|
|
18
|
+
],
|
|
19
|
+
"author": "deniis",
|
|
20
|
+
"license": "MIT",
|
|
21
|
+
"type": "module",
|
|
22
|
+
"main": "./index.js",
|
|
23
|
+
"types": "./index.d.ts",
|
|
24
|
+
"files": [
|
|
25
|
+
"pkg/rasmx_hash_bg.wasm",
|
|
26
|
+
"pkg/rasmx_hash.js",
|
|
27
|
+
"pkg/rasmx_hash.d.ts",
|
|
28
|
+
"index.js",
|
|
29
|
+
"index.d.ts",
|
|
30
|
+
"README.md",
|
|
31
|
+
"LICENSE"
|
|
32
|
+
],
|
|
33
|
+
"sideEffects": false,
|
|
34
|
+
"scripts": {
|
|
35
|
+
"build:wasm": "wasm-pack build ../../crates/rasmx_hash --target web --release --out-dir ../../packages/hash/pkg"
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,323 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
export class IncrementalBlake3 {
|
|
5
|
+
free(): void;
|
|
6
|
+
[Symbol.dispose](): void;
|
|
7
|
+
finalize(): string;
|
|
8
|
+
constructor();
|
|
9
|
+
update(data: Uint8Array): void;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export class IncrementalKeccak256 {
|
|
13
|
+
free(): void;
|
|
14
|
+
[Symbol.dispose](): void;
|
|
15
|
+
finalize(): string;
|
|
16
|
+
constructor();
|
|
17
|
+
update(data: Uint8Array): void;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export class IncrementalMd5 {
|
|
21
|
+
free(): void;
|
|
22
|
+
[Symbol.dispose](): void;
|
|
23
|
+
finalize(): string;
|
|
24
|
+
constructor();
|
|
25
|
+
update(data: Uint8Array): void;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export class IncrementalSha256 {
|
|
29
|
+
free(): void;
|
|
30
|
+
[Symbol.dispose](): void;
|
|
31
|
+
finalize(): string;
|
|
32
|
+
constructor();
|
|
33
|
+
update(data: Uint8Array): void;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export class IncrementalSha3_256 {
|
|
37
|
+
free(): void;
|
|
38
|
+
[Symbol.dispose](): void;
|
|
39
|
+
finalize(): string;
|
|
40
|
+
constructor();
|
|
41
|
+
update(data: Uint8Array): void;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export class IncrementalSha512 {
|
|
45
|
+
free(): void;
|
|
46
|
+
[Symbol.dispose](): void;
|
|
47
|
+
finalize(): string;
|
|
48
|
+
constructor();
|
|
49
|
+
update(data: Uint8Array): void;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export class IncrementalXxh3 {
|
|
53
|
+
free(): void;
|
|
54
|
+
[Symbol.dispose](): void;
|
|
55
|
+
finalize_128(): string;
|
|
56
|
+
finalize_64(): string;
|
|
57
|
+
constructor();
|
|
58
|
+
update(data: Uint8Array): void;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export class IncrementalXxh32 {
|
|
62
|
+
free(): void;
|
|
63
|
+
[Symbol.dispose](): void;
|
|
64
|
+
finalize(): string;
|
|
65
|
+
constructor(seed: number);
|
|
66
|
+
update(data: Uint8Array): void;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export class IncrementalXxh64 {
|
|
70
|
+
free(): void;
|
|
71
|
+
[Symbol.dispose](): void;
|
|
72
|
+
finalize(): string;
|
|
73
|
+
constructor(seed: bigint);
|
|
74
|
+
update(data: Uint8Array): void;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Computes BLAKE3 hash. Fast and secure.
|
|
79
|
+
*/
|
|
80
|
+
export function blake3_hex(data: Uint8Array): string;
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Computes keyed BLAKE3 hash. Key must be exactly 32 bytes.
|
|
84
|
+
*/
|
|
85
|
+
export function blake3_keyed_hex(data: Uint8Array, key: Uint8Array): string;
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Computes HMAC-SHA256 with a given key and data.
|
|
89
|
+
*/
|
|
90
|
+
export function hmac_sha256(key: Uint8Array, data: Uint8Array): string;
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Computes HMAC-SHA512 with a given key and data.
|
|
94
|
+
*/
|
|
95
|
+
export function hmac_sha512(key: Uint8Array, data: Uint8Array): string;
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Computes Keccak-224 hash.
|
|
99
|
+
*/
|
|
100
|
+
export function keccak_224(data: Uint8Array): string;
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Computes Keccak-256 hash.
|
|
104
|
+
*/
|
|
105
|
+
export function keccak_256(data: Uint8Array): string;
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Computes Keccak-384 hash.
|
|
109
|
+
*/
|
|
110
|
+
export function keccak_384(data: Uint8Array): string;
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Computes Keccak-512 hash.
|
|
114
|
+
*/
|
|
115
|
+
export function keccak_512(data: Uint8Array): string;
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Computes MD5 hash. Returns 32-character hex string.
|
|
119
|
+
*/
|
|
120
|
+
export function md5_hex(data: Uint8Array): string;
|
|
121
|
+
|
|
122
|
+
export function run_app(): void;
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Computes SHA-224 hash.
|
|
126
|
+
*/
|
|
127
|
+
export function sha2_224(data: Uint8Array): string;
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Computes SHA-256 hash.
|
|
131
|
+
*/
|
|
132
|
+
export function sha2_256(data: Uint8Array): string;
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Computes SHA-384 hash.
|
|
136
|
+
*/
|
|
137
|
+
export function sha2_384(data: Uint8Array): string;
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Computes SHA-512 hash.
|
|
141
|
+
*/
|
|
142
|
+
export function sha2_512(data: Uint8Array): string;
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Computes SHA-512/224 hash.
|
|
146
|
+
*/
|
|
147
|
+
export function sha2_512_224(data: Uint8Array): string;
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Computes SHA-512/256 hash.
|
|
151
|
+
*/
|
|
152
|
+
export function sha2_512_256(data: Uint8Array): string;
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Computes SHA3-224 hash.
|
|
156
|
+
*/
|
|
157
|
+
export function sha3_224(data: Uint8Array): string;
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Computes SHA3-256 hash.
|
|
161
|
+
*/
|
|
162
|
+
export function sha3_256(data: Uint8Array): string;
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Computes SHA3-384 hash.
|
|
166
|
+
*/
|
|
167
|
+
export function sha3_384(data: Uint8Array): string;
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Computes SHA3-512 hash.
|
|
171
|
+
*/
|
|
172
|
+
export function sha3_512(data: Uint8Array): string;
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* SHAKE-128: arbitrary-length output.
|
|
176
|
+
*/
|
|
177
|
+
export function shake128(data: Uint8Array, output_len: number): string;
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* SHAKE-256: arbitrary-length output.
|
|
181
|
+
*/
|
|
182
|
+
export function shake256(data: Uint8Array, output_len: number): string;
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* Computes XXH32 hash with a 32-bit seed.
|
|
186
|
+
*/
|
|
187
|
+
export function xxh32_hex(data: Uint8Array, seed: number): string;
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Computes XXH3 128-bit hash.
|
|
191
|
+
*/
|
|
192
|
+
export function xxh3_128_hex(data: Uint8Array): string;
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* Computes XXH3 128-bit hash with a 192-byte secret.
|
|
196
|
+
*/
|
|
197
|
+
export function xxh3_128_secret_hex(data: Uint8Array, secret: Uint8Array): string;
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Computes XXH3 128-bit hash with a 64-bit seed.
|
|
201
|
+
*/
|
|
202
|
+
export function xxh3_128_seed_hex(data: Uint8Array, seed: bigint): string;
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* Computes XXH3 64-bit hash. Fast and high quality.
|
|
206
|
+
*/
|
|
207
|
+
export function xxh3_64_hex(data: Uint8Array): string;
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* Computes XXH3 64-bit hash with a 192-byte secret.
|
|
211
|
+
*/
|
|
212
|
+
export function xxh3_64_secret_hex(data: Uint8Array, secret: Uint8Array): string;
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* Computes XXH3 64-bit hash with a 64-bit seed.
|
|
216
|
+
*/
|
|
217
|
+
export function xxh3_64_seed_hex(data: Uint8Array, seed: bigint): string;
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* Computes XXH64 hash with a 64-bit seed.
|
|
221
|
+
*/
|
|
222
|
+
export function xxh64_hex(data: Uint8Array, seed: bigint): string;
|
|
223
|
+
|
|
224
|
+
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
225
|
+
|
|
226
|
+
export interface InitOutput {
|
|
227
|
+
readonly memory: WebAssembly.Memory;
|
|
228
|
+
readonly __wbg_incrementalblake3_free: (a: number, b: number) => void;
|
|
229
|
+
readonly __wbg_incrementalkeccak256_free: (a: number, b: number) => void;
|
|
230
|
+
readonly __wbg_incrementalmd5_free: (a: number, b: number) => void;
|
|
231
|
+
readonly __wbg_incrementalsha256_free: (a: number, b: number) => void;
|
|
232
|
+
readonly __wbg_incrementalsha512_free: (a: number, b: number) => void;
|
|
233
|
+
readonly __wbg_incrementalxxh32_free: (a: number, b: number) => void;
|
|
234
|
+
readonly __wbg_incrementalxxh3_free: (a: number, b: number) => void;
|
|
235
|
+
readonly __wbg_incrementalxxh64_free: (a: number, b: number) => void;
|
|
236
|
+
readonly blake3_hex: (a: number, b: number) => [number, number];
|
|
237
|
+
readonly blake3_keyed_hex: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
238
|
+
readonly hmac_sha256: (a: number, b: number, c: number, d: number) => [number, number];
|
|
239
|
+
readonly hmac_sha512: (a: number, b: number, c: number, d: number) => [number, number];
|
|
240
|
+
readonly incrementalblake3_finalize: (a: number) => [number, number];
|
|
241
|
+
readonly incrementalblake3_new: () => number;
|
|
242
|
+
readonly incrementalblake3_update: (a: number, b: number, c: number) => void;
|
|
243
|
+
readonly incrementalkeccak256_finalize: (a: number) => [number, number];
|
|
244
|
+
readonly incrementalkeccak256_new: () => number;
|
|
245
|
+
readonly incrementalkeccak256_update: (a: number, b: number, c: number) => void;
|
|
246
|
+
readonly incrementalmd5_finalize: (a: number) => [number, number];
|
|
247
|
+
readonly incrementalmd5_new: () => number;
|
|
248
|
+
readonly incrementalmd5_update: (a: number, b: number, c: number) => void;
|
|
249
|
+
readonly incrementalsha256_finalize: (a: number) => [number, number];
|
|
250
|
+
readonly incrementalsha256_new: () => number;
|
|
251
|
+
readonly incrementalsha256_update: (a: number, b: number, c: number) => void;
|
|
252
|
+
readonly incrementalsha3_256_finalize: (a: number) => [number, number];
|
|
253
|
+
readonly incrementalsha512_finalize: (a: number) => [number, number];
|
|
254
|
+
readonly incrementalsha512_new: () => number;
|
|
255
|
+
readonly incrementalsha512_update: (a: number, b: number, c: number) => void;
|
|
256
|
+
readonly incrementalxxh32_finalize: (a: number) => [number, number];
|
|
257
|
+
readonly incrementalxxh32_new: (a: number) => number;
|
|
258
|
+
readonly incrementalxxh32_update: (a: number, b: number, c: number) => void;
|
|
259
|
+
readonly incrementalxxh3_finalize_128: (a: number) => [number, number];
|
|
260
|
+
readonly incrementalxxh3_finalize_64: (a: number) => [number, number];
|
|
261
|
+
readonly incrementalxxh3_new: () => number;
|
|
262
|
+
readonly incrementalxxh3_update: (a: number, b: number, c: number) => void;
|
|
263
|
+
readonly incrementalxxh64_finalize: (a: number) => [number, number];
|
|
264
|
+
readonly incrementalxxh64_new: (a: bigint) => number;
|
|
265
|
+
readonly incrementalxxh64_update: (a: number, b: number, c: number) => void;
|
|
266
|
+
readonly keccak_224: (a: number, b: number) => [number, number];
|
|
267
|
+
readonly keccak_256: (a: number, b: number) => [number, number];
|
|
268
|
+
readonly keccak_384: (a: number, b: number) => [number, number];
|
|
269
|
+
readonly keccak_512: (a: number, b: number) => [number, number];
|
|
270
|
+
readonly md5_hex: (a: number, b: number) => [number, number];
|
|
271
|
+
readonly sha2_224: (a: number, b: number) => [number, number];
|
|
272
|
+
readonly sha2_256: (a: number, b: number) => [number, number];
|
|
273
|
+
readonly sha2_384: (a: number, b: number) => [number, number];
|
|
274
|
+
readonly sha2_512: (a: number, b: number) => [number, number];
|
|
275
|
+
readonly sha2_512_224: (a: number, b: number) => [number, number];
|
|
276
|
+
readonly sha2_512_256: (a: number, b: number) => [number, number];
|
|
277
|
+
readonly sha3_224: (a: number, b: number) => [number, number];
|
|
278
|
+
readonly sha3_256: (a: number, b: number) => [number, number];
|
|
279
|
+
readonly sha3_384: (a: number, b: number) => [number, number];
|
|
280
|
+
readonly sha3_512: (a: number, b: number) => [number, number];
|
|
281
|
+
readonly shake128: (a: number, b: number, c: number) => [number, number];
|
|
282
|
+
readonly shake256: (a: number, b: number, c: number) => [number, number];
|
|
283
|
+
readonly xxh32_hex: (a: number, b: number, c: number) => [number, number];
|
|
284
|
+
readonly xxh3_128_hex: (a: number, b: number) => [number, number];
|
|
285
|
+
readonly xxh3_128_secret_hex: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
286
|
+
readonly xxh3_128_seed_hex: (a: number, b: number, c: bigint) => [number, number];
|
|
287
|
+
readonly xxh3_64_hex: (a: number, b: number) => [number, number];
|
|
288
|
+
readonly xxh3_64_secret_hex: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
289
|
+
readonly xxh3_64_seed_hex: (a: number, b: number, c: bigint) => [number, number];
|
|
290
|
+
readonly xxh64_hex: (a: number, b: number, c: bigint) => [number, number];
|
|
291
|
+
readonly run_app: () => void;
|
|
292
|
+
readonly incrementalsha3_256_new: () => number;
|
|
293
|
+
readonly __wbg_incrementalsha3_256_free: (a: number, b: number) => void;
|
|
294
|
+
readonly incrementalsha3_256_update: (a: number, b: number, c: number) => void;
|
|
295
|
+
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
296
|
+
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
297
|
+
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
298
|
+
readonly __wbindgen_externrefs: WebAssembly.Table;
|
|
299
|
+
readonly __externref_table_dealloc: (a: number) => void;
|
|
300
|
+
readonly __wbindgen_start: () => void;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
|
304
|
+
|
|
305
|
+
/**
|
|
306
|
+
* Instantiates the given `module`, which can either be bytes or
|
|
307
|
+
* a precompiled `WebAssembly.Module`.
|
|
308
|
+
*
|
|
309
|
+
* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
|
|
310
|
+
*
|
|
311
|
+
* @returns {InitOutput}
|
|
312
|
+
*/
|
|
313
|
+
export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
|
|
314
|
+
|
|
315
|
+
/**
|
|
316
|
+
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
|
317
|
+
* for everything else, calls `WebAssembly.instantiate` directly.
|
|
318
|
+
*
|
|
319
|
+
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
|
|
320
|
+
*
|
|
321
|
+
* @returns {Promise<InitOutput>}
|
|
322
|
+
*/
|
|
323
|
+
export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
|