rapidhash-js 2.2.0 → 3.0.1
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/CHANGELOG.md +11 -0
- package/README.md +100 -53
- package/lib/common.d.mts +7 -0
- package/lib/common.d.ts +7 -0
- package/lib/common.js +167 -0
- package/lib/common.js.map +1 -0
- package/lib/common.mjs +96 -0
- package/lib/common.mjs.map +1 -0
- package/lib/common_v2.js +26 -0
- package/lib/common_v2.js.map +1 -0
- package/lib/common_v2.mjs +15 -0
- package/lib/common_v2.mjs.map +1 -0
- package/lib/index.d.mts +2 -91
- package/lib/index.d.ts +2 -91
- package/lib/index.js +11 -467
- package/lib/index.mjs +1 -429
- package/lib/v1.0/index.d.mts +30 -0
- package/lib/v1.0/index.d.ts +30 -0
- package/lib/v1.0/index.js +106 -0
- package/lib/v1.0/index.js.map +1 -0
- package/lib/v1.0/index.mjs +103 -0
- package/lib/v1.0/index.mjs.map +1 -0
- package/lib/v2.0/index.d.mts +30 -0
- package/lib/v2.0/index.d.ts +30 -0
- package/lib/v2.0/index.js +128 -0
- package/lib/v2.0/index.js.map +1 -0
- package/lib/v2.0/index.mjs +125 -0
- package/lib/v2.0/index.mjs.map +1 -0
- package/lib/v2.2/index.d.mts +30 -0
- package/lib/v2.2/index.d.ts +30 -0
- package/lib/v2.2/index.js +128 -0
- package/lib/v2.2/index.js.map +1 -0
- package/lib/v2.2/index.mjs +125 -0
- package/lib/v2.2/index.mjs.map +1 -0
- package/lib/v3.0/index.d.mts +86 -0
- package/lib/v3.0/index.d.ts +86 -0
- package/lib/v3.0/index.js +11 -0
- package/lib/v3.0/index.mjs +1 -0
- package/lib/v3.0.js +407 -0
- package/lib/v3.0.js.map +1 -0
- package/lib/v3.0.mjs +354 -0
- package/lib/v3.0.mjs.map +1 -0
- package/package.json +23 -15
- package/lib/index.js.map +0 -1
- package/lib/index.mjs.map +0 -1
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { a as rapid_read32x2, c as rapid_readSmall, d as toDataView, f as validateOptions, l as rapidhash_epilogue_fast, n as rapid_mix_fast, o as rapid_read64, r as rapid_mix_protected, t as rapidMumImplementations, u as rapidhash_epilogue_protected } from "../common.mjs";
|
|
2
|
+
// src/v1.0/rapidhash_v1.0.ts
|
|
3
|
+
const RAPID_SEED = 13679853920966426665n;
|
|
4
|
+
const rapid_secret = [
|
|
5
|
+
3257665815644502181n,
|
|
6
|
+
10067880064238660809n,
|
|
7
|
+
5418857496715711651n
|
|
8
|
+
];
|
|
9
|
+
function rapidhash_v1_internal(key, seed, secret, rapid_mix, rapidhash_epilogue) {
|
|
10
|
+
const len = key.byteLength;
|
|
11
|
+
const lenBI = BigInt(key.byteLength);
|
|
12
|
+
seed ^= rapid_mix(seed ^ secret[0], secret[1]) ^ lenBI;
|
|
13
|
+
let a;
|
|
14
|
+
let b;
|
|
15
|
+
if (len <= 16) {
|
|
16
|
+
if (len >= 4) {
|
|
17
|
+
const last = len - 4;
|
|
18
|
+
a = rapid_read32x2(key, 0, last);
|
|
19
|
+
const delta = (len & 24) >> (len >> 3);
|
|
20
|
+
b = rapid_read32x2(key, delta, last - delta);
|
|
21
|
+
} else if (len > 0) {
|
|
22
|
+
a = rapid_readSmall(key, 0, len);
|
|
23
|
+
b = 0n;
|
|
24
|
+
} else {
|
|
25
|
+
a = 0n;
|
|
26
|
+
b = 0n;
|
|
27
|
+
}
|
|
28
|
+
} else {
|
|
29
|
+
let i = len;
|
|
30
|
+
let p = 0;
|
|
31
|
+
if (i > 48) {
|
|
32
|
+
let see1 = seed;
|
|
33
|
+
let see2 = seed;
|
|
34
|
+
while (i >= 96) {
|
|
35
|
+
seed = rapid_mix(rapid_read64(key, p) ^ secret[0], rapid_read64(key, p + 8) ^ seed);
|
|
36
|
+
see1 = rapid_mix(rapid_read64(key, p + 16) ^ secret[1], rapid_read64(key, p + 24) ^ see1);
|
|
37
|
+
see2 = rapid_mix(rapid_read64(key, p + 32) ^ secret[2], rapid_read64(key, p + 40) ^ see2);
|
|
38
|
+
seed = rapid_mix(rapid_read64(key, p + 48) ^ secret[0], rapid_read64(key, p + 56) ^ seed);
|
|
39
|
+
see1 = rapid_mix(rapid_read64(key, p + 64) ^ secret[1], rapid_read64(key, p + 72) ^ see1);
|
|
40
|
+
see2 = rapid_mix(rapid_read64(key, p + 80) ^ secret[2], rapid_read64(key, p + 88) ^ see2);
|
|
41
|
+
p += 96;
|
|
42
|
+
i -= 96;
|
|
43
|
+
}
|
|
44
|
+
if (i >= 48) {
|
|
45
|
+
seed = rapid_mix(rapid_read64(key, p) ^ secret[0], rapid_read64(key, p + 8) ^ seed);
|
|
46
|
+
see1 = rapid_mix(rapid_read64(key, p + 16) ^ secret[1], rapid_read64(key, p + 24) ^ see1);
|
|
47
|
+
see2 = rapid_mix(rapid_read64(key, p + 32) ^ secret[2], rapid_read64(key, p + 40) ^ see2);
|
|
48
|
+
p += 48;
|
|
49
|
+
i -= 48;
|
|
50
|
+
}
|
|
51
|
+
seed ^= see1 ^ see2;
|
|
52
|
+
}
|
|
53
|
+
if (i > 16) {
|
|
54
|
+
seed = rapid_mix(rapid_read64(key, p) ^ secret[2], rapid_read64(key, p + 8) ^ seed ^ secret[1]);
|
|
55
|
+
if (i > 32) seed = rapid_mix(rapid_read64(key, p + 16) ^ secret[2], rapid_read64(key, p + 24) ^ seed);
|
|
56
|
+
}
|
|
57
|
+
a = rapid_read64(key, p + i - 16);
|
|
58
|
+
b = rapid_read64(key, p + i - 8);
|
|
59
|
+
}
|
|
60
|
+
a ^= secret[1];
|
|
61
|
+
b ^= seed;
|
|
62
|
+
return rapidhash_epilogue(a, b, secret[0], secret[1], lenBI);
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Calculate a 64-bit hash value of the given message.
|
|
66
|
+
*
|
|
67
|
+
* @param message {string|Uint8Array|DataView} The message to be hashed.
|
|
68
|
+
* @param options Options for modifying the hash calculation.
|
|
69
|
+
* @param options.seed {bigint} 64-bit unsigned seed value.
|
|
70
|
+
* @param options.rapidMumBehaviour {'fast'|'protected'} Alters behaviour of the rapid_mum function. Defaults to 'fast'.
|
|
71
|
+
*/
|
|
72
|
+
function rapidhash_v1(message, options) {
|
|
73
|
+
const { seed, rapidMumBehaviour } = validateOptions(options, RAPID_SEED);
|
|
74
|
+
const { rapid_mix, rapidhash_epilogue } = rapidMumImplementations[rapidMumBehaviour];
|
|
75
|
+
return rapidhash_v1_internal(toDataView(message), seed, rapid_secret, rapid_mix, rapidhash_epilogue);
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Calculate a 64-bit hash value of the given message.
|
|
79
|
+
* This function is equivalent to rapidhash() with options.rapidMumBehaviour set to 'fast'.
|
|
80
|
+
*
|
|
81
|
+
* @param message {string|Uint8Array|DataView} The message to be hashed.
|
|
82
|
+
* @param options Options for modifying the hash calculation.
|
|
83
|
+
* @param options.seed {bigint} 64-bit unsigned seed value.
|
|
84
|
+
*/
|
|
85
|
+
function rapidhash_v1_fast(message, options) {
|
|
86
|
+
const { seed } = validateOptions(options, RAPID_SEED);
|
|
87
|
+
return rapidhash_v1_internal(toDataView(message), seed, rapid_secret, rapid_mix_fast, rapidhash_epilogue_fast);
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Calculate a 64-bit hash value of the given message.
|
|
91
|
+
* This function is equivalent to rapidhash() with options.rapidMumBehaviour set to 'protected'.
|
|
92
|
+
*
|
|
93
|
+
* @param message {string|Uint8Array|DataView} The message to be hashed.
|
|
94
|
+
* @param options Options for modifying the hash calculation.
|
|
95
|
+
* @param options.seed {bigint} 64-bit unsigned seed value.
|
|
96
|
+
*/
|
|
97
|
+
function rapidhash_v1_protected(message, options) {
|
|
98
|
+
const { seed } = validateOptions(options, RAPID_SEED);
|
|
99
|
+
return rapidhash_v1_internal(toDataView(message), seed, rapid_secret, rapid_mix_protected, rapidhash_epilogue_protected);
|
|
100
|
+
}
|
|
101
|
+
export { rapidhash_v1 as rapidhash, rapidhash_v1_fast as rapidhash_fast, rapidhash_v1_protected as rapidhash_protected };
|
|
102
|
+
|
|
103
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/v1.0/rapidhash_v1.0.ts"],"sourcesContent":["import {\n type RapidhashEpilogue,\n type RapidhashOptions,\n type RapidMix,\n rapid_mix_fast,\n rapid_mix_protected,\n rapid_read32x2,\n rapid_read64,\n rapid_readSmall,\n rapidhash_epilogue_fast,\n rapidhash_epilogue_protected,\n rapidMumImplementations,\n toDataView,\n validateOptions,\n} from '../common';\n\ntype RapidSecret = [bigint, bigint, bigint];\n\nconst RAPID_SEED = 0xbdd89aa982704029n;\nconst rapid_secret: RapidSecret = [0x2d358dccaa6c78a5n, 0x8bb84b93962eacc9n, 0x4b33a62ed433d4a3n];\n\n// ---\n\nfunction rapidhash_v1_internal(\n key: DataView,\n seed: bigint,\n secret: RapidSecret,\n rapid_mix: RapidMix,\n rapidhash_epilogue: RapidhashEpilogue,\n): bigint {\n const len = key.byteLength;\n const lenBI = BigInt(key.byteLength);\n\n seed ^= rapid_mix(seed ^ secret[0], secret[1]) ^ lenBI;\n\n let a: bigint;\n let b: bigint;\n\n if (len <= 16) {\n if (len >= 4) {\n const last = len - 4;\n a = rapid_read32x2(key, 0, last);\n const delta = (len & 24) >> (len >> 3);\n b = rapid_read32x2(key, delta, last - delta);\n } else if (len > 0) {\n a = rapid_readSmall(key, 0, len);\n b = 0n;\n } else {\n a = 0n;\n b = 0n;\n }\n } else {\n let i = len;\n let p = 0;\n\n if (i > 48) {\n let see1 = seed;\n let see2 = seed;\n\n while (i >= 96) {\n seed = rapid_mix(rapid_read64(key, p) ^ secret[0], rapid_read64(key, p + 8) ^ seed);\n see1 = rapid_mix(rapid_read64(key, p + 16) ^ secret[1], rapid_read64(key, p + 24) ^ see1);\n see2 = rapid_mix(rapid_read64(key, p + 32) ^ secret[2], rapid_read64(key, p + 40) ^ see2);\n seed = rapid_mix(rapid_read64(key, p + 48) ^ secret[0], rapid_read64(key, p + 56) ^ seed);\n see1 = rapid_mix(rapid_read64(key, p + 64) ^ secret[1], rapid_read64(key, p + 72) ^ see1);\n see2 = rapid_mix(rapid_read64(key, p + 80) ^ secret[2], rapid_read64(key, p + 88) ^ see2);\n p += 96;\n i -= 96;\n }\n if (i >= 48) {\n seed = rapid_mix(rapid_read64(key, p) ^ secret[0], rapid_read64(key, p + 8) ^ seed);\n see1 = rapid_mix(rapid_read64(key, p + 16) ^ secret[1], rapid_read64(key, p + 24) ^ see1);\n see2 = rapid_mix(rapid_read64(key, p + 32) ^ secret[2], rapid_read64(key, p + 40) ^ see2);\n p += 48;\n i -= 48;\n }\n\n seed ^= see1 ^ see2;\n }\n\n if (i > 16) {\n seed = rapid_mix(rapid_read64(key, p) ^ secret[2], rapid_read64(key, p + 8) ^ seed ^ secret[1]);\n if (i > 32) {\n seed = rapid_mix(rapid_read64(key, p + 16) ^ secret[2], rapid_read64(key, p + 24) ^ seed);\n }\n }\n a = rapid_read64(key, p + i - 16);\n b = rapid_read64(key, p + i - 8);\n }\n a ^= secret[1];\n b ^= seed;\n\n return rapidhash_epilogue(a, b, secret[0], secret[1], lenBI);\n}\n\n// ---\n\n/**\n * Calculate a 64-bit hash value of the given message.\n *\n * @param message {string|Uint8Array|DataView} The message to be hashed.\n * @param options Options for modifying the hash calculation.\n * @param options.seed {bigint} 64-bit unsigned seed value.\n * @param options.rapidMumBehaviour {'fast'|'protected'} Alters behaviour of the rapid_mum function. Defaults to 'fast'.\n */\nexport function rapidhash_v1(message: string | Uint8Array | DataView, options?: Partial<RapidhashOptions>): bigint {\n const {seed, rapidMumBehaviour} = validateOptions(options, RAPID_SEED);\n const {rapid_mix, rapidhash_epilogue} = rapidMumImplementations[rapidMumBehaviour];\n\n return rapidhash_v1_internal(toDataView(message), seed, rapid_secret, rapid_mix, rapidhash_epilogue);\n}\n\n/**\n * Calculate a 64-bit hash value of the given message.\n * This function is equivalent to rapidhash() with options.rapidMumBehaviour set to 'fast'.\n *\n * @param message {string|Uint8Array|DataView} The message to be hashed.\n * @param options Options for modifying the hash calculation.\n * @param options.seed {bigint} 64-bit unsigned seed value.\n */\nexport function rapidhash_v1_fast(\n message: string | Uint8Array | DataView,\n options?: Partial<Omit<RapidhashOptions, 'rapidMumBehaviour'>>,\n): bigint {\n const {seed} = validateOptions(options, RAPID_SEED);\n\n return rapidhash_v1_internal(toDataView(message), seed, rapid_secret, rapid_mix_fast, rapidhash_epilogue_fast);\n}\n\n/**\n * Calculate a 64-bit hash value of the given message.\n * This function is equivalent to rapidhash() with options.rapidMumBehaviour set to 'protected'.\n *\n * @param message {string|Uint8Array|DataView} The message to be hashed.\n * @param options Options for modifying the hash calculation.\n * @param options.seed {bigint} 64-bit unsigned seed value.\n */\nexport function rapidhash_v1_protected(\n message: string | Uint8Array | DataView,\n options?: Partial<Omit<RapidhashOptions, 'rapidMumBehaviour'>>,\n): bigint {\n const {seed} = validateOptions(options, RAPID_SEED);\n\n return rapidhash_v1_internal(\n toDataView(message),\n seed,\n rapid_secret,\n rapid_mix_protected,\n rapidhash_epilogue_protected,\n );\n}\n"],"mappings":";;AAkBA,MAAM,aAAa;AACnB,MAAM,eAA4B;CAAC;CAAqB;CAAqB;AAAmB;AAIhG,SAAS,sBACP,KACA,MACA,QACA,WACA,oBACQ;CACR,MAAM,MAAM,IAAI;CAChB,MAAM,QAAQ,OAAO,IAAI,UAAU;CAEnC,QAAQ,UAAU,OAAO,OAAO,IAAI,OAAO,EAAE,IAAI;CAEjD,IAAI;CACJ,IAAI;CAEJ,IAAI,OAAO,IAAI;EACb,IAAI,OAAO,GAAG;GACZ,MAAM,OAAO,MAAM;GACnB,IAAI,eAAe,KAAK,GAAG,IAAI;GAC/B,MAAM,SAAS,MAAM,QAAQ,OAAO;GACpC,IAAI,eAAe,KAAK,OAAO,OAAO,KAAK;EAC7C,OAAO,IAAI,MAAM,GAAG;GAClB,IAAI,gBAAg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Aa,KAAK,IAAI,CAAC,IAAI,OAAO,OAAO,EAAE;GAC9F,IAAI,IAAI,IACN,OAAO,UAAU,aAAa,KAAK,IAAI,EAAE,IAAI,OAAO,IAAI,aAAa,KAAK,IAAI,EAAE,IAAI,IAAI;EAE5F;EACA,IAAI,aAAa,KAAK,IAAI,IAAI,EAAE;EAChC,IAAI,aAAa,KAAK,IAAI,IAAI,CAAC;CACjC;CACA,KAAK,OAAO;CACZ,KAAK;CAEL,OAAO,mBAAmB,GAAG,GAAG,OAAO,IAAI,OAAO,IAAI,KAAK;AAC7D;;;;;;;;;AAYA,SAAgB,aAAa,SAAyC,SAA6C;CACjH,MAAM,EAAC,MAAM,sBAAqB,gBAAgB,SAAS,UAAU;CACrE,MAAM,EAAC,WAAW,uBAAsB,wBAAwB;CAEhE,OAAO,sBAAsB,WAAW,OAAO,GAAG,MAAM,cAAc,WAAW,kBAAkB;AACrG;;;;;;;;;AAUA,SAAgB,kBACd,SACA,SACQ;CACR,MAAM,EAAC,SAAQ,gBAAgB,SAAS,UAAU;CAElD,OAAO,sBAAsB,WAAW,OAAO,GAAG,MAAM,cAAc,gBAAgB,uBAAuB;AAC/G;;;;;;;;;AAUA,SAAgB,uBACd,SACA,SACQ;CACR,MAAM,EAAC,SAAQ,gBAAgB,SAAS,UAAU;CAElD,OAAO,sBACL,WAAW,OAAO,GAClB,MACA,cACA,qBACA,4BACF;AACF"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { t as RapidhashOptions } from "../common.mjs";
|
|
2
|
+
/**
|
|
3
|
+
* Calculate a 64-bit hash value of the given message.
|
|
4
|
+
*
|
|
5
|
+
* @param message {string|Uint8Array|DataView} The message to be hashed.
|
|
6
|
+
* @param options Options for modifying the hash calculation.
|
|
7
|
+
* @param options.seed {bigint} 64-bit unsigned seed value.
|
|
8
|
+
* @param options.rapidMumBehaviour {'fast'|'protected'} Alters behaviour of the rapid_mum function. Defaults to 'fast'.
|
|
9
|
+
*/
|
|
10
|
+
declare function rapidhash_v2_0(message: string | Uint8Array | DataView, options?: Partial<RapidhashOptions>): bigint;
|
|
11
|
+
/**
|
|
12
|
+
* Calculate a 64-bit hash value of the given message.
|
|
13
|
+
* This function is equivalent to rapidhash() with options.rapidMumBehaviour set to 'fast'.
|
|
14
|
+
*
|
|
15
|
+
* @param message {string|Uint8Array|DataView} The message to be hashed.
|
|
16
|
+
* @param options Options for modifying the hash calculation.
|
|
17
|
+
* @param options.seed {bigint} 64-bit unsigned seed value.
|
|
18
|
+
*/
|
|
19
|
+
declare function rapidhash_v2_0_fast(message: string | Uint8Array | DataView, options?: Partial<Omit<RapidhashOptions, 'rapidMumBehaviour'>>): bigint;
|
|
20
|
+
/**
|
|
21
|
+
* Calculate a 64-bit hash value of the given message.
|
|
22
|
+
* This function is equivalent to rapidhash() with options.rapidMumBehaviour set to 'protected'.
|
|
23
|
+
*
|
|
24
|
+
* @param message {string|Uint8Array|DataView} The message to be hashed.
|
|
25
|
+
* @param options Options for modifying the hash calculation.
|
|
26
|
+
* @param options.seed {bigint} 64-bit unsigned seed value.
|
|
27
|
+
*/
|
|
28
|
+
declare function rapidhash_v2_0_protected(message: string | Uint8Array | DataView, options?: Partial<Omit<RapidhashOptions, 'rapidMumBehaviour'>>): bigint;
|
|
29
|
+
export { rapidhash_v2_0 as rapidhash, rapidhash_v2_0_fast as rapidhash_fast, rapidhash_v2_0_protected as rapidhash_protected };
|
|
30
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { t as RapidhashOptions } from "../common.js";
|
|
2
|
+
/**
|
|
3
|
+
* Calculate a 64-bit hash value of the given message.
|
|
4
|
+
*
|
|
5
|
+
* @param message {string|Uint8Array|DataView} The message to be hashed.
|
|
6
|
+
* @param options Options for modifying the hash calculation.
|
|
7
|
+
* @param options.seed {bigint} 64-bit unsigned seed value.
|
|
8
|
+
* @param options.rapidMumBehaviour {'fast'|'protected'} Alters behaviour of the rapid_mum function. Defaults to 'fast'.
|
|
9
|
+
*/
|
|
10
|
+
declare function rapidhash_v2_0(message: string | Uint8Array | DataView, options?: Partial<RapidhashOptions>): bigint;
|
|
11
|
+
/**
|
|
12
|
+
* Calculate a 64-bit hash value of the given message.
|
|
13
|
+
* This function is equivalent to rapidhash() with options.rapidMumBehaviour set to 'fast'.
|
|
14
|
+
*
|
|
15
|
+
* @param message {string|Uint8Array|DataView} The message to be hashed.
|
|
16
|
+
* @param options Options for modifying the hash calculation.
|
|
17
|
+
* @param options.seed {bigint} 64-bit unsigned seed value.
|
|
18
|
+
*/
|
|
19
|
+
declare function rapidhash_v2_0_fast(message: string | Uint8Array | DataView, options?: Partial<Omit<RapidhashOptions, 'rapidMumBehaviour'>>): bigint;
|
|
20
|
+
/**
|
|
21
|
+
* Calculate a 64-bit hash value of the given message.
|
|
22
|
+
* This function is equivalent to rapidhash() with options.rapidMumBehaviour set to 'protected'.
|
|
23
|
+
*
|
|
24
|
+
* @param message {string|Uint8Array|DataView} The message to be hashed.
|
|
25
|
+
* @param options Options for modifying the hash calculation.
|
|
26
|
+
* @param options.seed {bigint} 64-bit unsigned seed value.
|
|
27
|
+
*/
|
|
28
|
+
declare function rapidhash_v2_0_protected(message: string | Uint8Array | DataView, options?: Partial<Omit<RapidhashOptions, 'rapidMumBehaviour'>>): bigint;
|
|
29
|
+
export { rapidhash_v2_0 as rapidhash, rapidhash_v2_0_fast as rapidhash_fast, rapidhash_v2_0_protected as rapidhash_protected };
|
|
30
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_common = require("../common.js");
|
|
3
|
+
const require_common_v2 = require("../common_v2.js");
|
|
4
|
+
// src/v2.0/rapidhash_v2.0.ts
|
|
5
|
+
function rapidhash_v2_0_internal(key, seed, secret, rapid_mix, rapidhash_epilogue) {
|
|
6
|
+
const len = key.byteLength;
|
|
7
|
+
const lenBI = BigInt(key.byteLength);
|
|
8
|
+
seed ^= rapid_mix(seed ^ secret[2], secret[1]) ^ lenBI;
|
|
9
|
+
let a;
|
|
10
|
+
let b;
|
|
11
|
+
if (len <= 16) {
|
|
12
|
+
if (len >= 4) {
|
|
13
|
+
if (len >= 8) {
|
|
14
|
+
const last = len - 8;
|
|
15
|
+
a = require_common.rapid_read64(key, 0);
|
|
16
|
+
b = require_common.rapid_read64(key, last);
|
|
17
|
+
} else {
|
|
18
|
+
const last = len - 4;
|
|
19
|
+
a = require_common.rapid_read32(key, 0);
|
|
20
|
+
b = require_common.rapid_read32(key, last);
|
|
21
|
+
}
|
|
22
|
+
} else if (len > 0) {
|
|
23
|
+
a = require_common.rapid_readSmall(key, 0, len);
|
|
24
|
+
b = 0n;
|
|
25
|
+
} else {
|
|
26
|
+
a = 0n;
|
|
27
|
+
b = 0n;
|
|
28
|
+
}
|
|
29
|
+
} else if (len > 56) {
|
|
30
|
+
let i = len;
|
|
31
|
+
let p = 0;
|
|
32
|
+
let see1 = seed;
|
|
33
|
+
let see2 = seed;
|
|
34
|
+
let see3456;
|
|
35
|
+
if (i >= 112) {
|
|
36
|
+
let see3 = seed;
|
|
37
|
+
let see4 = seed;
|
|
38
|
+
let see5 = seed;
|
|
39
|
+
let see6 = seed;
|
|
40
|
+
do {
|
|
41
|
+
seed = rapid_mix(require_common.rapid_read64(key, p) ^ secret[0], require_common.rapid_read64(key, p + 8) ^ seed);
|
|
42
|
+
see1 = rapid_mix(require_common.rapid_read64(key, p + 16) ^ secret[1], require_common.rapid_read64(key, p + 24) ^ see1);
|
|
43
|
+
see2 = rapid_mix(require_common.rapid_read64(key, p + 32) ^ secret[2], require_common.rapid_read64(key, p + 40) ^ see2);
|
|
44
|
+
see3 = rapid_mix(require_common.rapid_read64(key, p + 48) ^ secret[3], require_common.rapid_read64(key, p + 56) ^ see3);
|
|
45
|
+
see4 = rapid_mix(require_common.rapid_read64(key, p + 64) ^ secret[4], require_common.rapid_read64(key, p + 72) ^ see4);
|
|
46
|
+
see5 = rapid_mix(require_common.rapid_read64(key, p + 80) ^ secret[5], require_common.rapid_read64(key, p + 88) ^ see5);
|
|
47
|
+
see6 = rapid_mix(require_common.rapid_read64(key, p + 96) ^ secret[6], require_common.rapid_read64(key, p + 104) ^ see6);
|
|
48
|
+
p += 112;
|
|
49
|
+
i -= 112;
|
|
50
|
+
} while (i >= 112);
|
|
51
|
+
see3456 = see3 ^ see4 ^ see5 ^ see6;
|
|
52
|
+
} else see3456 = 0n;
|
|
53
|
+
if (i >= 48) {
|
|
54
|
+
seed = rapid_mix(require_common.rapid_read64(key, p) ^ secret[0], require_common.rapid_read64(key, p + 8) ^ seed);
|
|
55
|
+
see1 = rapid_mix(require_common.rapid_read64(key, p + 16) ^ secret[1], require_common.rapid_read64(key, p + 24) ^ see1);
|
|
56
|
+
see2 = rapid_mix(require_common.rapid_read64(key, p + 32) ^ secret[2], require_common.rapid_read64(key, p + 40) ^ see2);
|
|
57
|
+
p += 48;
|
|
58
|
+
i -= 48;
|
|
59
|
+
if (i >= 48) {
|
|
60
|
+
seed = rapid_mix(require_common.rapid_read64(key, p) ^ secret[0], require_common.rapid_read64(key, p + 8) ^ seed);
|
|
61
|
+
see1 = rapid_mix(require_common.rapid_read64(key, p + 16) ^ secret[1], require_common.rapid_read64(key, p + 24) ^ see1);
|
|
62
|
+
see2 = rapid_mix(require_common.rapid_read64(key, p + 32) ^ secret[2], require_common.rapid_read64(key, p + 40) ^ see2);
|
|
63
|
+
p += 48;
|
|
64
|
+
i -= 48;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
seed ^= see1 ^ see2 ^ see3456;
|
|
68
|
+
if (i > 16) {
|
|
69
|
+
seed = rapid_mix(require_common.rapid_read64(key, p) ^ secret[2], require_common.rapid_read64(key, p + 8) ^ seed);
|
|
70
|
+
if (i > 32) seed = rapid_mix(require_common.rapid_read64(key, p + 16) ^ secret[2], require_common.rapid_read64(key, p + 24) ^ seed);
|
|
71
|
+
}
|
|
72
|
+
a = require_common.rapid_read64(key, p + i - 16);
|
|
73
|
+
b = require_common.rapid_read64(key, p + i - 8);
|
|
74
|
+
} else {
|
|
75
|
+
seed = rapid_mix(require_common.rapid_read64(key, 0) ^ secret[0], require_common.rapid_read64(key, 8) ^ seed);
|
|
76
|
+
if (len > 32) {
|
|
77
|
+
seed = rapid_mix(require_common.rapid_read64(key, 16) ^ secret[1], require_common.rapid_read64(key, 24) ^ seed);
|
|
78
|
+
if (len > 48) seed = rapid_mix(require_common.rapid_read64(key, 32) ^ secret[0], require_common.rapid_read64(key, 40) ^ seed);
|
|
79
|
+
}
|
|
80
|
+
a = require_common.rapid_read64(key, len - 16);
|
|
81
|
+
b = require_common.rapid_read64(key, len - 8);
|
|
82
|
+
}
|
|
83
|
+
a ^= secret[1];
|
|
84
|
+
b ^= seed;
|
|
85
|
+
return rapidhash_epilogue(a, b, secret[7], secret[1], lenBI);
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Calculate a 64-bit hash value of the given message.
|
|
89
|
+
*
|
|
90
|
+
* @param message {string|Uint8Array|DataView} The message to be hashed.
|
|
91
|
+
* @param options Options for modifying the hash calculation.
|
|
92
|
+
* @param options.seed {bigint} 64-bit unsigned seed value.
|
|
93
|
+
* @param options.rapidMumBehaviour {'fast'|'protected'} Alters behaviour of the rapid_mum function. Defaults to 'fast'.
|
|
94
|
+
*/
|
|
95
|
+
function rapidhash_v2_0(message, options) {
|
|
96
|
+
const { seed, rapidMumBehaviour } = require_common.validateOptions(options, require_common_v2.RAPID_SEED);
|
|
97
|
+
const { rapid_mix, rapidhash_epilogue } = require_common.rapidMumImplementations[rapidMumBehaviour];
|
|
98
|
+
return rapidhash_v2_0_internal(require_common.toDataView(message), seed, require_common_v2.rapid_secret, rapid_mix, rapidhash_epilogue);
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Calculate a 64-bit hash value of the given message.
|
|
102
|
+
* This function is equivalent to rapidhash() with options.rapidMumBehaviour set to 'fast'.
|
|
103
|
+
*
|
|
104
|
+
* @param message {string|Uint8Array|DataView} The message to be hashed.
|
|
105
|
+
* @param options Options for modifying the hash calculation.
|
|
106
|
+
* @param options.seed {bigint} 64-bit unsigned seed value.
|
|
107
|
+
*/
|
|
108
|
+
function rapidhash_v2_0_fast(message, options) {
|
|
109
|
+
const { seed } = require_common.validateOptions(options, require_common_v2.RAPID_SEED);
|
|
110
|
+
return rapidhash_v2_0_internal(require_common.toDataView(message), seed, require_common_v2.rapid_secret, require_common.rapid_mix_fast, require_common.rapidhash_epilogue_fast);
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Calculate a 64-bit hash value of the given message.
|
|
114
|
+
* This function is equivalent to rapidhash() with options.rapidMumBehaviour set to 'protected'.
|
|
115
|
+
*
|
|
116
|
+
* @param message {string|Uint8Array|DataView} The message to be hashed.
|
|
117
|
+
* @param options Options for modifying the hash calculation.
|
|
118
|
+
* @param options.seed {bigint} 64-bit unsigned seed value.
|
|
119
|
+
*/
|
|
120
|
+
function rapidhash_v2_0_protected(message, options) {
|
|
121
|
+
const { seed } = require_common.validateOptions(options, require_common_v2.RAPID_SEED);
|
|
122
|
+
return rapidhash_v2_0_internal(require_common.toDataView(message), seed, require_common_v2.rapid_secret, require_common.rapid_mix_protected, require_common.rapidhash_epilogue_protected);
|
|
123
|
+
}
|
|
124
|
+
exports.rapidhash = rapidhash_v2_0;
|
|
125
|
+
exports.rapidhash_fast = rapidhash_v2_0_fast;
|
|
126
|
+
exports.rapidhash_protected = rapidhash_v2_0_protected;
|
|
127
|
+
|
|
128
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["rapid_read64","rapid_read32","rapid_readSmall","validateOptions","RAPID_SEED","rapidMumImplementations","toDataView","rapid_secret","rapid_mix_fast","rapidhash_epilogue_fast","rapid_mix_protected","rapidhash_epilogue_protected"],"sources":["../../src/v2.0/rapidhash_v2.0.ts"],"sourcesContent":["import {\n type RapidhashEpilogue,\n type RapidhashOptions,\n type RapidMix,\n rapid_mix_fast,\n rapid_mix_protected,\n rapid_read32,\n rapid_read64,\n rapid_readSmall,\n rapidhash_epilogue_fast,\n rapidhash_epilogue_protected,\n rapidMumImplementations,\n toDataView,\n validateOptions,\n} from '../common';\nimport {RAPID_SEED, type RapidSecret, rapid_secret} from '../common_v2';\n\n// ---\n\nfunction rapidhash_v2_0_internal(\n key: DataView,\n seed: bigint,\n secret: RapidSecret,\n rapid_mix: RapidMix,\n rapidhash_epilogue: RapidhashEpilogue,\n): bigint {\n const len = key.byteLength;\n const lenBI = BigInt(key.byteLength);\n\n seed ^= rapid_mix(seed ^ secret[2], secret[1]) ^ lenBI;\n\n let a: bigint;\n let b: bigint;\n\n if (len <= 16) {\n if (len >= 4) {\n if (len >= 8) {\n const last = len - 8;\n a = rapid_read64(key, 0);\n b = rapid_read64(key, last);\n } else {\n const last = len - 4;\n a = rapid_read32(key, 0);\n b = rapid_read32(key, last);\n }\n } else if (len > 0) {\n a = rapid_readSmall(key, 0, len);\n b = 0n;\n } else {\n a = 0n;\n b = 0n;\n }\n } else if (len > 56) {\n let i = len;\n let p = 0;\n let see1 = seed;\n let see2 = seed;\n let see3456: bigint;\n\n if (i >= 112) {\n let see3 = seed;\n let see4 = seed;\n let see5 = seed;\n let see6 = seed;\n do {\n seed = rapid_mix(rapid_read64(key, p) ^ secret[0], rapid_read64(key, p + 8) ^ seed);\n see1 = rapid_mix(rapid_read64(key, p + 16) ^ secret[1], rapid_read64(key, p + 24) ^ see1);\n see2 = rapid_mix(rapid_read64(key, p + 32) ^ secret[2], rapid_read64(key, p + 40) ^ see2);\n see3 = rapid_mix(rapid_read64(key, p + 48) ^ secret[3], rapid_read64(key, p + 56) ^ see3);\n see4 = rapid_mix(rapid_read64(key, p + 64) ^ secret[4], rapid_read64(key, p + 72) ^ see4);\n see5 = rapid_mix(rapid_read64(key, p + 80) ^ secret[5], rapid_read64(key, p + 88) ^ see5);\n see6 = rapid_mix(rapid_read64(key, p + 96) ^ secret[6], rapid_read64(key, p + 104) ^ see6);\n p += 112;\n i -= 112;\n } while (i >= 112);\n\n see3456 = see3 ^ see4 ^ see5 ^ see6;\n } else {\n see3456 = 0n;\n }\n\n if (i >= 48) {\n seed = rapid_mix(rapid_read64(key, p) ^ secret[0], rapid_read64(key, p + 8) ^ seed);\n see1 = rapid_mix(rapid_read64(key, p + 16) ^ secret[1], rapid_read64(key, p + 24) ^ see1);\n see2 = rapid_mix(rapid_read64(key, p + 32) ^ secret[2], rapid_read64(key, p + 40) ^ see2);\n p += 48;\n i -= 48;\n if (i >= 48) {\n seed = rapid_mix(rapid_read64(key, p) ^ secret[0], rapid_read64(key, p + 8) ^ seed);\n see1 = rapid_mix(rapid_read64(key, p + 16) ^ secret[1], rapid_read64(key, p + 24) ^ see1);\n see2 = rapid_mix(rapid_read64(key, p + 32) ^ secret[2], rapid_read64(key, p + 40) ^ see2);\n p += 48;\n i -= 48;\n }\n }\n\n seed ^= see1 ^ see2 ^ see3456;\n\n if (i > 16) {\n seed = rapid_mix(rapid_read64(key, p) ^ secret[2], rapid_read64(key, p + 8) ^ seed);\n if (i > 32) {\n seed = rapid_mix(rapid_read64(key, p + 16) ^ secret[2], rapid_read64(key, p + 24) ^ seed);\n }\n }\n\n a = rapid_read64(key, p + i - 16);\n b = rapid_read64(key, p + i - 8);\n } else {\n seed = rapid_mix(rapid_read64(key, 0) ^ secret[0], rapid_read64(key, 8) ^ seed);\n if (len > 32) {\n seed = rapid_mix(rapid_read64(key, 16) ^ secret[1], rapid_read64(key, 24) ^ seed);\n if (len > 48) {\n seed = rapid_mix(rapid_read64(key, 32) ^ secret[0], rapid_read64(key, 40) ^ seed);\n }\n }\n\n a = rapid_read64(key, len - 16);\n b = rapid_read64(key, len - 8);\n }\n a ^= secret[1];\n b ^= seed;\n\n return rapidhash_epilogue(a, b, secret[7], secret[1], lenBI);\n}\n\n// ---\n\n/**\n * Calculate a 64-bit hash value of the given message.\n *\n * @param message {string|Uint8Array|DataView} The message to be hashed.\n * @param options Options for modifying the hash calculation.\n * @param options.seed {bigint} 64-bit unsigned seed value.\n * @param options.rapidMumBehaviour {'fast'|'protected'} Alters behaviour of the rapid_mum function. Defaults to 'fast'.\n */\nexport function rapidhash_v2_0(message: string | Uint8Array | DataView, options?: Partial<RapidhashOptions>): bigint {\n const {seed, rapidMumBehaviour} = validateOptions(options, RAPID_SEED);\n const {rapid_mix, rapidhash_epilogue} = rapidMumImplementations[rapidMumBehaviour];\n\n return rapidhash_v2_0_internal(toDataView(message), seed, rapid_secret, rapid_mix, rapidhash_epilogue);\n}\n\n/**\n * Calculate a 64-bit hash value of the given message.\n * This function is equivalent to rapidhash() with options.rapidMumBehaviour set to 'fast'.\n *\n * @param message {string|Uint8Array|DataView} The message to be hashed.\n * @param options Options for modifying the hash calculation.\n * @param options.seed {bigint} 64-bit unsigned seed value.\n */\nexport function rapidhash_v2_0_fast(\n message: string | Uint8Array | DataView,\n options?: Partial<Omit<RapidhashOptions, 'rapidMumBehaviour'>>,\n): bigint {\n const {seed} = validateOptions(options, RAPID_SEED);\n\n return rapidhash_v2_0_internal(toDataView(message), seed, rapid_secret, rapid_mix_fast, rapidhash_epilogue_fast);\n}\n\n/**\n * Calculate a 64-bit hash value of the given message.\n * This function is equivalent to rapidhash() with options.rapidMumBehaviour set to 'protected'.\n *\n * @param message {string|Uint8Array|DataView} The message to be hashed.\n * @param options Options for modifying the hash calculation.\n * @param options.seed {bigint} 64-bit unsigned seed value.\n */\nexport function rapidhash_v2_0_protected(\n message: string | Uint8Array | DataView,\n options?: Partial<Omit<RapidhashOptions, 'rapidMumBehaviour'>>,\n): bigint {\n const {seed} = validateOptions(options, RAPID_SEED);\n\n return rapidhash_v2_0_internal(\n toDataView(message),\n seed,\n rapid_secret,\n rapid_mix_protected,\n rapidhash_epilogue_protected,\n );\n}\n"],"mappings":";;;;AAmBA,SAAS,wBACP,KACA,MACA,QACA,WACA,oBAC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,gBAAgB,SAASC,kBAAAA,UAAU;CAElD,OAAO,wBAAwBE,eAAAA,WAAW,OAAO,GAAG,MAAMC,kBAAAA,cAAcC,eAAAA,gBAAgBC,eAAAA,uBAAuB;AACjH;;;;;;;;;AAUA,SAAgB,yBACd,SACA,SACQ;CACR,MAAM,EAAC,SAAQN,eAAAA,gBAAgB,SAASC,kBAAAA,UAAU;CAElD,OAAO,wBACLE,eAAAA,WAAW,OAAO,GAClB,MACAC,kBAAAA,cACAG,eAAAA,qBACAC,eAAAA,4BACF;AACF"}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { c as rapid_readSmall, d as toDataView, f as validateOptions, i as rapid_read32, l as rapidhash_epilogue_fast, n as rapid_mix_fast, o as rapid_read64, r as rapid_mix_protected, t as rapidMumImplementations, u as rapidhash_epilogue_protected } from "../common.mjs";
|
|
2
|
+
import { n as rapid_secret, t as RAPID_SEED } from "../common_v2.mjs";
|
|
3
|
+
// src/v2.0/rapidhash_v2.0.ts
|
|
4
|
+
function rapidhash_v2_0_internal(key, seed, secret, rapid_mix, rapidhash_epilogue) {
|
|
5
|
+
const len = key.byteLength;
|
|
6
|
+
const lenBI = BigInt(key.byteLength);
|
|
7
|
+
seed ^= rapid_mix(seed ^ secret[2], secret[1]) ^ lenBI;
|
|
8
|
+
let a;
|
|
9
|
+
let b;
|
|
10
|
+
if (len <= 16) {
|
|
11
|
+
if (len >= 4) {
|
|
12
|
+
if (len >= 8) {
|
|
13
|
+
const last = len - 8;
|
|
14
|
+
a = rapid_read64(key, 0);
|
|
15
|
+
b = rapid_read64(key, last);
|
|
16
|
+
} else {
|
|
17
|
+
const last = len - 4;
|
|
18
|
+
a = rapid_read32(key, 0);
|
|
19
|
+
b = rapid_read32(key, last);
|
|
20
|
+
}
|
|
21
|
+
} else if (len > 0) {
|
|
22
|
+
a = rapid_readSmall(key, 0, len);
|
|
23
|
+
b = 0n;
|
|
24
|
+
} else {
|
|
25
|
+
a = 0n;
|
|
26
|
+
b = 0n;
|
|
27
|
+
}
|
|
28
|
+
} else if (len > 56) {
|
|
29
|
+
let i = len;
|
|
30
|
+
let p = 0;
|
|
31
|
+
let see1 = seed;
|
|
32
|
+
let see2 = seed;
|
|
33
|
+
let see3456;
|
|
34
|
+
if (i >= 112) {
|
|
35
|
+
let see3 = seed;
|
|
36
|
+
let see4 = seed;
|
|
37
|
+
let see5 = seed;
|
|
38
|
+
let see6 = seed;
|
|
39
|
+
do {
|
|
40
|
+
seed = rapid_mix(rapid_read64(key, p) ^ secret[0], rapid_read64(key, p + 8) ^ seed);
|
|
41
|
+
see1 = rapid_mix(rapid_read64(key, p + 16) ^ secret[1], rapid_read64(key, p + 24) ^ see1);
|
|
42
|
+
see2 = rapid_mix(rapid_read64(key, p + 32) ^ secret[2], rapid_read64(key, p + 40) ^ see2);
|
|
43
|
+
see3 = rapid_mix(rapid_read64(key, p + 48) ^ secret[3], rapid_read64(key, p + 56) ^ see3);
|
|
44
|
+
see4 = rapid_mix(rapid_read64(key, p + 64) ^ secret[4], rapid_read64(key, p + 72) ^ see4);
|
|
45
|
+
see5 = rapid_mix(rapid_read64(key, p + 80) ^ secret[5], rapid_read64(key, p + 88) ^ see5);
|
|
46
|
+
see6 = rapid_mix(rapid_read64(key, p + 96) ^ secret[6], rapid_read64(key, p + 104) ^ see6);
|
|
47
|
+
p += 112;
|
|
48
|
+
i -= 112;
|
|
49
|
+
} while (i >= 112);
|
|
50
|
+
see3456 = see3 ^ see4 ^ see5 ^ see6;
|
|
51
|
+
} else see3456 = 0n;
|
|
52
|
+
if (i >= 48) {
|
|
53
|
+
seed = rapid_mix(rapid_read64(key, p) ^ secret[0], rapid_read64(key, p + 8) ^ seed);
|
|
54
|
+
see1 = rapid_mix(rapid_read64(key, p + 16) ^ secret[1], rapid_read64(key, p + 24) ^ see1);
|
|
55
|
+
see2 = rapid_mix(rapid_read64(key, p + 32) ^ secret[2], rapid_read64(key, p + 40) ^ see2);
|
|
56
|
+
p += 48;
|
|
57
|
+
i -= 48;
|
|
58
|
+
if (i >= 48) {
|
|
59
|
+
seed = rapid_mix(rapid_read64(key, p) ^ secret[0], rapid_read64(key, p + 8) ^ seed);
|
|
60
|
+
see1 = rapid_mix(rapid_read64(key, p + 16) ^ secret[1], rapid_read64(key, p + 24) ^ see1);
|
|
61
|
+
see2 = rapid_mix(rapid_read64(key, p + 32) ^ secret[2], rapid_read64(key, p + 40) ^ see2);
|
|
62
|
+
p += 48;
|
|
63
|
+
i -= 48;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
seed ^= see1 ^ see2 ^ see3456;
|
|
67
|
+
if (i > 16) {
|
|
68
|
+
seed = rapid_mix(rapid_read64(key, p) ^ secret[2], rapid_read64(key, p + 8) ^ seed);
|
|
69
|
+
if (i > 32) seed = rapid_mix(rapid_read64(key, p + 16) ^ secret[2], rapid_read64(key, p + 24) ^ seed);
|
|
70
|
+
}
|
|
71
|
+
a = rapid_read64(key, p + i - 16);
|
|
72
|
+
b = rapid_read64(key, p + i - 8);
|
|
73
|
+
} else {
|
|
74
|
+
seed = rapid_mix(rapid_read64(key, 0) ^ secret[0], rapid_read64(key, 8) ^ seed);
|
|
75
|
+
if (len > 32) {
|
|
76
|
+
seed = rapid_mix(rapid_read64(key, 16) ^ secret[1], rapid_read64(key, 24) ^ seed);
|
|
77
|
+
if (len > 48) seed = rapid_mix(rapid_read64(key, 32) ^ secret[0], rapid_read64(key, 40) ^ seed);
|
|
78
|
+
}
|
|
79
|
+
a = rapid_read64(key, len - 16);
|
|
80
|
+
b = rapid_read64(key, len - 8);
|
|
81
|
+
}
|
|
82
|
+
a ^= secret[1];
|
|
83
|
+
b ^= seed;
|
|
84
|
+
return rapidhash_epilogue(a, b, secret[7], secret[1], lenBI);
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Calculate a 64-bit hash value of the given message.
|
|
88
|
+
*
|
|
89
|
+
* @param message {string|Uint8Array|DataView} The message to be hashed.
|
|
90
|
+
* @param options Options for modifying the hash calculation.
|
|
91
|
+
* @param options.seed {bigint} 64-bit unsigned seed value.
|
|
92
|
+
* @param options.rapidMumBehaviour {'fast'|'protected'} Alters behaviour of the rapid_mum function. Defaults to 'fast'.
|
|
93
|
+
*/
|
|
94
|
+
function rapidhash_v2_0(message, options) {
|
|
95
|
+
const { seed, rapidMumBehaviour } = validateOptions(options, RAPID_SEED);
|
|
96
|
+
const { rapid_mix, rapidhash_epilogue } = rapidMumImplementations[rapidMumBehaviour];
|
|
97
|
+
return rapidhash_v2_0_internal(toDataView(message), seed, rapid_secret, rapid_mix, rapidhash_epilogue);
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Calculate a 64-bit hash value of the given message.
|
|
101
|
+
* This function is equivalent to rapidhash() with options.rapidMumBehaviour set to 'fast'.
|
|
102
|
+
*
|
|
103
|
+
* @param message {string|Uint8Array|DataView} The message to be hashed.
|
|
104
|
+
* @param options Options for modifying the hash calculation.
|
|
105
|
+
* @param options.seed {bigint} 64-bit unsigned seed value.
|
|
106
|
+
*/
|
|
107
|
+
function rapidhash_v2_0_fast(message, options) {
|
|
108
|
+
const { seed } = validateOptions(options, RAPID_SEED);
|
|
109
|
+
return rapidhash_v2_0_internal(toDataView(message), seed, rapid_secret, rapid_mix_fast, rapidhash_epilogue_fast);
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Calculate a 64-bit hash value of the given message.
|
|
113
|
+
* This function is equivalent to rapidhash() with options.rapidMumBehaviour set to 'protected'.
|
|
114
|
+
*
|
|
115
|
+
* @param message {string|Uint8Array|DataView} The message to be hashed.
|
|
116
|
+
* @param options Options for modifying the hash calculation.
|
|
117
|
+
* @param options.seed {bigint} 64-bit unsigned seed value.
|
|
118
|
+
*/
|
|
119
|
+
function rapidhash_v2_0_protected(message, options) {
|
|
120
|
+
const { seed } = validateOptions(options, RAPID_SEED);
|
|
121
|
+
return rapidhash_v2_0_internal(toDataView(message), seed, rapid_secret, rapid_mix_protected, rapidhash_epilogue_protected);
|
|
122
|
+
}
|
|
123
|
+
export { rapidhash_v2_0 as rapidhash, rapidhash_v2_0_fast as rapidhash_fast, rapidhash_v2_0_protected as rapidhash_protected };
|
|
124
|
+
|
|
125
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/v2.0/rapidhash_v2.0.ts"],"sourcesContent":["import {\n type RapidhashEpilogue,\n type RapidhashOptions,\n type RapidMix,\n rapid_mix_fast,\n rapid_mix_protected,\n rapid_read32,\n rapid_read64,\n rapid_readSmall,\n rapidhash_epilogue_fast,\n rapidhash_epilogue_protected,\n rapidMumImplementations,\n toDataView,\n validateOptions,\n} from '../common';\nimport {RAPID_SEED, type RapidSecret, rapid_secret} from '../common_v2';\n\n// ---\n\nfunction rapidhash_v2_0_internal(\n key: DataView,\n seed: bigint,\n secret: RapidSecret,\n rapid_mix: RapidMix,\n rapidhash_epilogue: RapidhashEpilogue,\n): bigint {\n const len = key.byteLength;\n const lenBI = BigInt(key.byteLength);\n\n seed ^= rapid_mix(seed ^ secret[2], secret[1]) ^ lenBI;\n\n let a: bigint;\n let b: bigint;\n\n if (len <= 16) {\n if (len >= 4) {\n if (len >= 8) {\n const last = len - 8;\n a = rapid_read64(key, 0);\n b = rapid_read64(key, last);\n } else {\n const last = len - 4;\n a = rapid_read32(key, 0);\n b = rapid_read32(key, last);\n }\n } else if (len > 0) {\n a = rapid_readSmall(key, 0, len);\n b = 0n;\n } else {\n a = 0n;\n b = 0n;\n }\n } else if (len > 56) {\n let i = len;\n let p = 0;\n let see1 = seed;\n let see2 = seed;\n let see3456: bigint;\n\n if (i >= 112) {\n let see3 = seed;\n let see4 = seed;\n let see5 = seed;\n let see6 = seed;\n do {\n seed = rapid_mix(rapid_read64(key, p) ^ secret[0], rapid_read64(key, p + 8) ^ seed);\n see1 = rapid_mix(rapid_read64(key, p + 16) ^ secret[1], rapid_read64(key, p + 24) ^ see1);\n see2 = rapid_mix(rapid_read64(key, p + 32) ^ secret[2], rapid_read64(key, p + 40) ^ see2);\n see3 = rapid_mix(rapid_read64(key, p + 48) ^ secret[3], rapid_read64(key, p + 56) ^ see3);\n see4 = rapid_mix(rapid_read64(key, p + 64) ^ secret[4], rapid_read64(key, p + 72) ^ see4);\n see5 = rapid_mix(rapid_read64(key, p + 80) ^ secret[5], rapid_read64(key, p + 88) ^ see5);\n see6 = rapid_mix(rapid_read64(key, p + 96) ^ secret[6], rapid_read64(key, p + 104) ^ see6);\n p += 112;\n i -= 112;\n } while (i >= 112);\n\n see3456 = see3 ^ see4 ^ see5 ^ see6;\n } else {\n see3456 = 0n;\n }\n\n if (i >= 48) {\n seed = rapid_mix(rapid_read64(key, p) ^ secret[0], rapid_read64(key, p + 8) ^ seed);\n see1 = rapid_mix(rapid_read64(key, p + 16) ^ secret[1], rapid_read64(key, p + 24) ^ see1);\n see2 = rapid_mix(rapid_read64(key, p + 32) ^ secret[2], rapid_read64(key, p + 40) ^ see2);\n p += 48;\n i -= 48;\n if (i >= 48) {\n seed = rapid_mix(rapid_read64(key, p) ^ secret[0], rapid_read64(key, p + 8) ^ seed);\n see1 = rapid_mix(rapid_read64(key, p + 16) ^ secret[1], rapid_read64(key, p + 24) ^ see1);\n see2 = rapid_mix(rapid_read64(key, p + 32) ^ secret[2], rapid_read64(key, p + 40) ^ see2);\n p += 48;\n i -= 48;\n }\n }\n\n seed ^= see1 ^ see2 ^ see3456;\n\n if (i > 16) {\n seed = rapid_mix(rapid_read64(key, p) ^ secret[2], rapid_read64(key, p + 8) ^ seed);\n if (i > 32) {\n seed = rapid_mix(rapid_read64(key, p + 16) ^ secret[2], rapid_read64(key, p + 24) ^ seed);\n }\n }\n\n a = rapid_read64(key, p + i - 16);\n b = rapid_read64(key, p + i - 8);\n } else {\n seed = rapid_mix(rapid_read64(key, 0) ^ secret[0], rapid_read64(key, 8) ^ seed);\n if (len > 32) {\n seed = rapid_mix(rapid_read64(key, 16) ^ secret[1], rapid_read64(key, 24) ^ seed);\n if (len > 48) {\n seed = rapid_mix(rapid_read64(key, 32) ^ secret[0], rapid_read64(key, 40) ^ seed);\n }\n }\n\n a = rapid_read64(key, len - 16);\n b = rapid_read64(key, len - 8);\n }\n a ^= secret[1];\n b ^= seed;\n\n return rapidhash_epilogue(a, b, secret[7], secret[1], lenBI);\n}\n\n// ---\n\n/**\n * Calculate a 64-bit hash value of the given message.\n *\n * @param message {string|Uint8Array|DataView} The message to be hashed.\n * @param options Options for modifying the hash calculation.\n * @param options.seed {bigint} 64-bit unsigned seed value.\n * @param options.rapidMumBehaviour {'fast'|'protected'} Alters behaviour of the rapid_mum function. Defaults to 'fast'.\n */\nexport function rapidhash_v2_0(message: string | Uint8Array | DataView, options?: Partial<RapidhashOptions>): bigint {\n const {seed, rapidMumBehaviour} = validateOptions(options, RAPID_SEED);\n const {rapid_mix, rapidhash_epilogue} = rapidMumImplementations[rapidMumBehaviour];\n\n return rapidhash_v2_0_internal(toDataView(message), seed, rapid_secret, rapid_mix, rapidhash_epilogue);\n}\n\n/**\n * Calculate a 64-bit hash value of the given message.\n * This function is equivalent to rapidhash() with options.rapidMumBehaviour set to 'fast'.\n *\n * @param message {string|Uint8Array|DataView} The message to be hashed.\n * @param options Options for modifying the hash calculation.\n * @param options.seed {bigint} 64-bit unsigned seed value.\n */\nexport function rapidhash_v2_0_fast(\n message: string | Uint8Array | DataView,\n options?: Partial<Omit<RapidhashOptions, 'rapidMumBehaviour'>>,\n): bigint {\n const {seed} = validateOptions(options, RAPID_SEED);\n\n return rapidhash_v2_0_internal(toDataView(message), seed, rapid_secret, rapid_mix_fast, rapidhash_epilogue_fast);\n}\n\n/**\n * Calculate a 64-bit hash value of the given message.\n * This function is equivalent to rapidhash() with options.rapidMumBehaviour set to 'protected'.\n *\n * @param message {string|Uint8Array|DataView} The message to be hashed.\n * @param options Options for modifying the hash calculation.\n * @param options.seed {bigint} 64-bit unsigned seed value.\n */\nexport function rapidhash_v2_0_protected(\n message: string | Uint8Array | DataView,\n options?: Partial<Omit<RapidhashOptions, 'rapidMumBehaviour'>>,\n): bigint {\n const {seed} = validateOptions(options, RAPID_SEED);\n\n return rapidhash_v2_0_internal(\n toDataView(message),\n seed,\n rapid_secret,\n rapid_mix_protected,\n rapidhash_epilogue_protected,\n );\n}\n"],"mappings":";;;AAmBA,SAAS,wBACP,KACA,MACA,QACA,WACA,oBACQ;CACR,MAAM,MAAM,IAAI;CAChB,MAAM,QAAQ,OAAO,IAAI,UAAU;CAEnC,QAAQ,UAAU,OAAO,OAAO,IAAI,OAAO,EAAE,IAAI;CAEjD,IAAI;CACJ,IAAI;CAEJ,IAAI,OAAO,IAAI;EACb,IAAI,OAAO,GAAG;GACZ,IAAI,OAAO,GAAG;IACZ,MAAM,OAAO,MAAM;IACnB,IAAI,aAAa,KAAK,CAAC;IACvB,IAAI,aAAa,KAAK,IAAI;GAC5B,OAAO;IACL,MAAM,OAAO,MAAM;IACnB,IAAI,aAAa,KAAK,CAAC;IACvB,IAAI,aAAa,KAAK,IAAI;GAC5B;EACF,OAAO,IAAI,MAAM,GAAG;GAClB,IAAI,gBAAgB,KAAK,GAAG,GAAG;GAC/B,IAAI;EACN,OAAO;GACL,IAAI;GACJ,IAAI;EACN;CACF,OAAO,IAAI,MAAM,IAAI;EACnB,IAAI,IAAI;EACR,IAAI,IAAI;EACR,IAAI,OAAO;EACX,IAAI,OAAO;EACX,IAAI;EAEJ,IAAI,KAAK,KAAK;GACZ,IAAI,OAAO;GACX,IAAI,OAAO;GACX,IAAI,OAAO;GACX,IAAI,OAAO;GACX,GAAG;IACD,OAAO,UAAU,aAAa,KAAK,CAAC,IAAI,OAAO,IAAI,aAAa,KAAK,IAAI,CAAC,IAAI,IAAI;IAClF,OAAO,UAAU,aAAa,KAAK,IAAI,EAAE,IAAI,OAAO,IAAI,aAAa,KAAK,IAAI,EAAE,IAAI,IAAI;IACxF,OAAO,UAAU,aAAa,KAAK,IAAI,EAAE,IAAI,OAAO,IAAI,aA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,OAAO,wBACL,WAAW,OAAO,GAClB,MACA,cACA,qBACA,4BACF;AACF"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { t as RapidhashOptions } from "../common.mjs";
|
|
2
|
+
/**
|
|
3
|
+
* Calculate a 64-bit hash value of the given message.
|
|
4
|
+
*
|
|
5
|
+
* @param message {string|Uint8Array|DataView} The message to be hashed.
|
|
6
|
+
* @param options Options for modifying the hash calculation.
|
|
7
|
+
* @param options.seed {bigint} 64-bit unsigned seed value.
|
|
8
|
+
* @param options.rapidMumBehaviour {'fast'|'protected'} Alters behaviour of the rapid_mum function. Defaults to 'fast'.
|
|
9
|
+
*/
|
|
10
|
+
declare function rapidhash_v2_2(message: string | Uint8Array | DataView, options?: Partial<RapidhashOptions>): bigint;
|
|
11
|
+
/**
|
|
12
|
+
* Calculate a 64-bit hash value of the given message.
|
|
13
|
+
* This function is equivalent to rapidhash() with options.rapidMumBehaviour set to 'fast'.
|
|
14
|
+
*
|
|
15
|
+
* @param message {string|Uint8Array|DataView} The message to be hashed.
|
|
16
|
+
* @param options Options for modifying the hash calculation.
|
|
17
|
+
* @param options.seed {bigint} 64-bit unsigned seed value.
|
|
18
|
+
*/
|
|
19
|
+
declare function rapidhash_v2_2_fast(message: string | Uint8Array | DataView, options?: Partial<Omit<RapidhashOptions, 'rapidMumBehaviour'>>): bigint;
|
|
20
|
+
/**
|
|
21
|
+
* Calculate a 64-bit hash value of the given message.
|
|
22
|
+
* This function is equivalent to rapidhash() with options.rapidMumBehaviour set to 'protected'.
|
|
23
|
+
*
|
|
24
|
+
* @param message {string|Uint8Array|DataView} The message to be hashed.
|
|
25
|
+
* @param options Options for modifying the hash calculation.
|
|
26
|
+
* @param options.seed {bigint} 64-bit unsigned seed value.
|
|
27
|
+
*/
|
|
28
|
+
declare function rapidhash_v2_2_protected(message: string | Uint8Array | DataView, options?: Partial<Omit<RapidhashOptions, 'rapidMumBehaviour'>>): bigint;
|
|
29
|
+
export { rapidhash_v2_2 as rapidhash, rapidhash_v2_2_fast as rapidhash_fast, rapidhash_v2_2_protected as rapidhash_protected };
|
|
30
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { t as RapidhashOptions } from "../common.js";
|
|
2
|
+
/**
|
|
3
|
+
* Calculate a 64-bit hash value of the given message.
|
|
4
|
+
*
|
|
5
|
+
* @param message {string|Uint8Array|DataView} The message to be hashed.
|
|
6
|
+
* @param options Options for modifying the hash calculation.
|
|
7
|
+
* @param options.seed {bigint} 64-bit unsigned seed value.
|
|
8
|
+
* @param options.rapidMumBehaviour {'fast'|'protected'} Alters behaviour of the rapid_mum function. Defaults to 'fast'.
|
|
9
|
+
*/
|
|
10
|
+
declare function rapidhash_v2_2(message: string | Uint8Array | DataView, options?: Partial<RapidhashOptions>): bigint;
|
|
11
|
+
/**
|
|
12
|
+
* Calculate a 64-bit hash value of the given message.
|
|
13
|
+
* This function is equivalent to rapidhash() with options.rapidMumBehaviour set to 'fast'.
|
|
14
|
+
*
|
|
15
|
+
* @param message {string|Uint8Array|DataView} The message to be hashed.
|
|
16
|
+
* @param options Options for modifying the hash calculation.
|
|
17
|
+
* @param options.seed {bigint} 64-bit unsigned seed value.
|
|
18
|
+
*/
|
|
19
|
+
declare function rapidhash_v2_2_fast(message: string | Uint8Array | DataView, options?: Partial<Omit<RapidhashOptions, 'rapidMumBehaviour'>>): bigint;
|
|
20
|
+
/**
|
|
21
|
+
* Calculate a 64-bit hash value of the given message.
|
|
22
|
+
* This function is equivalent to rapidhash() with options.rapidMumBehaviour set to 'protected'.
|
|
23
|
+
*
|
|
24
|
+
* @param message {string|Uint8Array|DataView} The message to be hashed.
|
|
25
|
+
* @param options Options for modifying the hash calculation.
|
|
26
|
+
* @param options.seed {bigint} 64-bit unsigned seed value.
|
|
27
|
+
*/
|
|
28
|
+
declare function rapidhash_v2_2_protected(message: string | Uint8Array | DataView, options?: Partial<Omit<RapidhashOptions, 'rapidMumBehaviour'>>): bigint;
|
|
29
|
+
export { rapidhash_v2_2 as rapidhash, rapidhash_v2_2_fast as rapidhash_fast, rapidhash_v2_2_protected as rapidhash_protected };
|
|
30
|
+
//# sourceMappingURL=index.d.ts.map
|