e845b595a8
* feat: add encryption key loading to server deployment * feat: add encryption key generation script
23 lines
609 B
TypeScript
23 lines
609 B
TypeScript
import _sodium from 'libsodium-wrappers'
|
|
|
|
import { CommandModule } from 'yargs'
|
|
|
|
const command: CommandModule = {
|
|
command: 'generateKeyPair',
|
|
describe: 'Generate a public private key pair for lisodium box encryption',
|
|
|
|
handler: async () => {
|
|
console.log('generating a key pair')
|
|
await _sodium.ready
|
|
const sodium = _sodium
|
|
const { publicKey, privateKey } = sodium.crypto_box_keypair()
|
|
const out = {
|
|
publicKey: Buffer.from(publicKey).toString('base64'),
|
|
privateKey: Buffer.from(privateKey).toString('base64')
|
|
}
|
|
console.log('generated', out)
|
|
}
|
|
}
|
|
|
|
export = command
|