age-encryption
is a TypeScript implementation of the
age file encryption format.
All low-level cryptographic operations are implemented with libsodium.js.
npm install age-encryption
import * as age from "age-encryption"
await (async() => {
const identity = await age.generateIdentity()
const recipient = await age.identityToRecipient(identity)
console.log(identity)
console.log(recipient)
const e = new age.Encrypter()
await e.addRecipient(recipient)
const ciphertext = await e.encrypt("Hello, age!")
const d = new age.Decrypter()
await d.addIdentity(identity)
const out = await d.decrypt(ciphertext, "text")
console.log(out)
})()
await (async() => {
const e = new age.Encrypter()
e.setPassphrase("burst-swarm-slender-curve-ability-various-crystal-moon-affair-three")
const ciphertext = await e.encrypt("Hello, age!")
const d = new age.Decrypter()
d.addPassphrase("burst-swarm-slender-curve-ability-various-crystal-moon-affair-three")
const out = await d.decrypt(ciphertext, "text")
console.log(out)
})()