Serialized AES-GCM 256 encryption, decryption and key management in the browser & Node.js
npm install @47ng/cloak@47ng/cloak



Serialized AES-GCM 256 encryption, decryption and key management in the browser & Node.js.
``shell`
$ yarn add @47ng/cloakor
$ npm i @47ng/cloak
The package comes with a CLI tool you can use to generate and manage keys, as
well as encrypting and decrypting data in the terminal:
`shell
$ cloak --help
Usage: cloak [options] [command]
Options:
-h, --help output usage information
Commands:
generate Generate an AES-GCM key
encrypt [options] [key] Encrypt stdin
decrypt Decrypt stdin
revoke
keychain [options] [full] List the contents of the environment keychain
Generated new empty keychain:
export CLOAK_MASTER_KEY=k1.aesgcm256.DL2G9PQeZ9r65J59pph6dy9Sk4fBLEZ3CTQZsandgYE=
export CLOAK_KEYCHAIN=v1.aesgcm256.6f28c026.yhCUkzv5gOyHJ2M_.jrGSf2_MPVofk-kSDgnYzvEy
Updated keychain:
export CLOAK_MASTER_KEY=k1.aesgcm256.DL2G9PQeZ9r65J59pph6dy9Sk4fBLEZ3CTQZsandgYE=
export CLOAK_KEYCHAIN=v1.aesgcm256.6f28c026.jr9fqMA_RfNhIjHz.lo4IfIYfZ0zxrdSns_ibWq6YX1D5AnzN-fhUF0CKVx5dRVIo0x-Atumr9WZqpHOeEIWT5bEGFKHhxGkFdwk2vg5TZQNk5Rj_jo3hnfSLaFAYncG59dB jUkz1JE0Plq2d-GR1AbDs6P18VzOG_JrU
To use this new key as default for encryption:
export CLOAK_CURRENT_KEY=cd38bcc4
Programmatic Usage
`ts
// Works in the browser or in Node.jsimport { generateKey, encryptString, decryptString } from '@47ng/cloak'
const demo = async () => {
const key = generateKey()
const cipher = await encryptString('Hello, World', key)
const decipher = await decryptString(cipher, key)
}
``MIT - Made with ❤️ by François Best
Using this package at work ? Sponsor me to help with support and maintenance.