+1
-1
README.md
+1
-1
README.md
···
8
8
9
9
[anproto.com](https://anproto.com)
10
10
11
-
+ [Deno/Browser implementation](https://github.com/evbogue/anproto) [by Evbogue]
11
+
+ [JavaScript implementation](https://github.com/evbogue/anproto) [by Evbogue]
12
12
+ [Golang implementation](https://github.com/vic/goan) [by Vic]
13
13
14
14
try it at [anproto.com/try](https://anproto.com/try) or use a client such as [wiredove](https://wiredove.net/)
+1
-1
ex.js
+1
-1
ex.js
+35
node_ex.js
+35
node_ex.js
···
1
+
// get an.js working in Node.js -- from https://github.com/vic/goan/blob/main/js_helper.js
2
+
3
+
import { createRequire } from 'module';
4
+
const require = createRequire(import.meta.url);
5
+
6
+
globalThis.self = {
7
+
crypto: {
8
+
getRandomValues: (buf) => {
9
+
require('crypto').randomFillSync(buf);
10
+
return buf;
11
+
}
12
+
}
13
+
};
14
+
15
+
if (typeof globalThis.crypto === 'undefined' || typeof globalThis.crypto.subtle === 'undefined') {
16
+
globalThis.crypto = globalThis.crypto || {};
17
+
try {
18
+
globalThis.crypto.subtle = require('crypto').webcrypto.subtle;
19
+
} catch (e) {
20
+
console.log(e)
21
+
}
22
+
}
23
+
24
+
const { an } = await import('./an.js');
25
+
26
+
const m = "Hello World";
27
+
const h = await an.hash(m);
28
+
const k = await an.gen();
29
+
const s = await an.sign(h, k);
30
+
const o = await an.open(s);
31
+
32
+
console.log(k);
33
+
console.log(h);
34
+
console.log(s);
35
+
console.log(o);