Skip to content
/ age.ts Public
forked from FiloSottile/typage

A TypeScript implementation of the age file encryption format, based on libsodium.

License

Notifications You must be signed in to change notification settings

mirshko/age.ts

 
 

Repository files navigation

The age logo, an wireframe of St. Peters dome in Rome, with the text: age, file encryption

age-encryption is a TypeScript implementation of the age file encryption format.

All low-level cryptographic operations are implemented with libsodium.js.

⚠️ This project is experimental. The author has near-zero JavaScript experience and help is very welcome. ⚠️

Installation

npm install age-encryption

Usage

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)
})()

About

A TypeScript implementation of the age file encryption format, based on libsodium.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 98.4%
  • JavaScript 1.6%