mirror of
https://github.com/HeyPuter/puter
synced 2024-11-15 06:15:47 +00:00
20 lines
443 B
JavaScript
20 lines
443 B
JavaScript
|
const nacl = require('tweetnacl');
|
||
|
|
||
|
const pair = nacl.box.keyPair();
|
||
|
|
||
|
const format_key = key => {
|
||
|
const version = new Uint8Array([0x31]);
|
||
|
const buffer = Buffer.concat([
|
||
|
Buffer.from(version),
|
||
|
Buffer.from(key),
|
||
|
]);
|
||
|
return buffer.toString('base64');
|
||
|
};
|
||
|
|
||
|
console.log(JSON.stringify({
|
||
|
keys: {
|
||
|
public: format_key(pair.publicKey),
|
||
|
secret: format_key(pair.secretKey),
|
||
|
},
|
||
|
}, undefined, ' '));
|