rapier-markdown-kit 1.1.92 → 1.1.93
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/dist/kit/ledger/hash.mjs +22 -16
- package/package.json +1 -1
package/dist/kit/ledger/hash.mjs
CHANGED
|
@@ -21,27 +21,33 @@ const K = new Uint32Array([
|
|
|
21
21
|
0x19a4c116,0x1e376c08,0x2748774c,0x34b0bcb5,0x391c0cb3,0x4ed8aa4a,0x5b9cca4f,0x682e6ff3,
|
|
22
22
|
0x748f82ee,0x78a5636f,0x84c87814,0x8cc70208,0x90befffa,0xa4506ceb,0xbef9a3f7,0xc67178f2,
|
|
23
23
|
]);
|
|
24
|
-
|
|
24
|
+
// The rounds run on plain 32-bit locals: no array is made per block, so a megabyte (a painting's text) hashes about five times
|
|
25
|
+
// faster than through destructured arrays, with the same digest.
|
|
26
|
+
const W = new Int32Array(64);
|
|
25
27
|
export function sha256(text) {
|
|
26
|
-
const bytes = new TextEncoder().encode(text);
|
|
27
|
-
const padded = new Uint8Array(Math.ceil((
|
|
28
|
-
padded.set(bytes); padded[
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
28
|
+
const bytes = new TextEncoder().encode(text), length = bytes.length;
|
|
29
|
+
const padded = new Uint8Array(Math.ceil((length + 9) / 64) * 64), end = padded.length;
|
|
30
|
+
padded.set(bytes); padded[length] = 0x80;
|
|
31
|
+
const high = Math.floor(length * 8 / 0x100000000), low = (length * 8) >>> 0;
|
|
32
|
+
padded[end - 8] = high >>> 24; padded[end - 7] = high >>> 16; padded[end - 6] = high >>> 8; padded[end - 5] = high;
|
|
33
|
+
padded[end - 4] = low >>> 24; padded[end - 3] = low >>> 16; padded[end - 2] = low >>> 8; padded[end - 1] = low;
|
|
34
|
+
let h0 = 0x6a09e667 | 0, h1 = 0xbb67ae85 | 0, h2 = 0x3c6ef372 | 0, h3 = 0xa54ff53a | 0, h4 = 0x510e527f | 0, h5 = 0x9b05688c | 0, h6 = 0x1f83d9ab | 0, h7 = 0x5be0cd19 | 0;
|
|
35
|
+
const w = W;
|
|
36
|
+
for (let offset = 0; offset < end; offset += 64) {
|
|
37
|
+
for (let i = 0, j = offset; i < 16; i++, j += 4) w[i] = padded[j] << 24 | padded[j + 1] << 16 | padded[j + 2] << 8 | padded[j + 3];
|
|
34
38
|
for (let i = 16; i < 64; i++) {
|
|
35
39
|
const x = w[i - 15], y = w[i - 2];
|
|
36
|
-
w[i] = w[i - 16] + (
|
|
40
|
+
w[i] = (w[i - 16] + ((x >>> 7 | x << 25) ^ (x >>> 18 | x << 14) ^ x >>> 3) + w[i - 7] + ((y >>> 17 | y << 15) ^ (y >>> 19 | y << 13) ^ y >>> 10)) | 0;
|
|
37
41
|
}
|
|
38
|
-
let
|
|
42
|
+
let a = h0, b = h1, c = h2, d = h3, e = h4, f = h5, g = h6, k = h7;
|
|
39
43
|
for (let i = 0; i < 64; i++) {
|
|
40
|
-
const t1 = (k + (
|
|
41
|
-
const t2 = ((
|
|
42
|
-
k = g; g = f; f = e; e = (d + t1)
|
|
44
|
+
const t1 = (k + ((e >>> 6 | e << 26) ^ (e >>> 11 | e << 21) ^ (e >>> 25 | e << 7)) + (e & f ^ ~e & g) + K[i] + w[i]) | 0;
|
|
45
|
+
const t2 = (((a >>> 2 | a << 30) ^ (a >>> 13 | a << 19) ^ (a >>> 22 | a << 10)) + (a & b ^ a & c ^ b & c)) | 0;
|
|
46
|
+
k = g; g = f; f = e; e = (d + t1) | 0; d = c; c = b; b = a; a = (t1 + t2) | 0;
|
|
43
47
|
}
|
|
44
|
-
|
|
48
|
+
h0 = (h0 + a) | 0; h1 = (h1 + b) | 0; h2 = (h2 + c) | 0; h3 = (h3 + d) | 0; h4 = (h4 + e) | 0; h5 = (h5 + f) | 0; h6 = (h6 + g) | 0; h7 = (h7 + k) | 0;
|
|
45
49
|
}
|
|
46
|
-
|
|
50
|
+
let out = '';
|
|
51
|
+
for (const x of [h0, h1, h2, h3, h4, h5, h6, h7]) out += (x >>> 0).toString(16).padStart(8, '0');
|
|
52
|
+
return out;
|
|
47
53
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rapier-markdown-kit",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.93",
|
|
4
4
|
"description": "Read, render and write Self-contained Markdown: one .md file that carries its pictures, drawings and layout, and that any Markdown app can read. HTML renderer, stylesheet, text layout, Will/1 agent permissions, and an edit history with authorship and offline merge. MIT, no dependencies.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"markdown",
|