49 lines
2 KiB
HTML
49 lines
2 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="utf-8" />
|
|
<title>Verae rapid SHA-256 (WASM)</title>
|
|
<style>
|
|
body { font-family: system-ui, sans-serif; max-width: 40rem; margin: 2rem auto; padding: 0 1rem; }
|
|
code, pre { background: #f1f5f9; padding: .2rem .4rem; border-radius: 4px; }
|
|
pre { padding: 1rem; overflow: auto; }
|
|
#out { margin-top: 1rem; word-break: break-all; }
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<h1>Verae SHA-256 WASM</h1>
|
|
<p>Client-side rapid hashing for Zapier Code steps, browser apps, and Peergos. Hash locally, then send only the hex to <code>POST /v1/timestamp</code>.</p>
|
|
<input type="file" id="file" />
|
|
<pre id="out">Pick a file…</pre>
|
|
<h2>TS / JS import</h2>
|
|
<pre>import init, { sha256_hex_js, Sha256Stream } from './verae_sha256.js';
|
|
await init();
|
|
const hex = sha256_hex_js(new TextEncoder().encode('hello'));
|
|
// streaming:
|
|
const s = new Sha256Stream();
|
|
s.update(chunk); const digest = s.finish();</pre>
|
|
<p>Also available: <code>datacube_hasher.js</code> (<code>compute_sha256</code>, <code>StreamingHasher</code>).</p>
|
|
<script type="module">
|
|
import init, { sha256_hex_js, Sha256Stream } from './verae_sha256.js';
|
|
const out = document.getElementById('out');
|
|
await init();
|
|
out.textContent = 'WASM ready. sha256("hello") = ' + sha256_hex_js(new TextEncoder().encode('hello'));
|
|
document.getElementById('file').addEventListener('change', async (e) => {
|
|
const f = e.target.files?.[0];
|
|
if (!f) return;
|
|
out.textContent = `Hashing ${f.name} (${f.size} bytes)…`;
|
|
const stream = new Sha256Stream();
|
|
const reader = f.stream().getReader();
|
|
const t0 = performance.now();
|
|
while (true) {
|
|
const { done, value } = await reader.read();
|
|
if (done) break;
|
|
stream.update(value);
|
|
}
|
|
const hex = stream.finish();
|
|
const ms = (performance.now() - t0).toFixed(1);
|
|
out.textContent = `${f.name}\nsha256: ${hex}\n${ms} ms`;
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>
|