casper

Package Version Hex Docs

Casper is an opinionated encryption library which offers ChaCha20-Poly1305 via Erlang or Node. Note: the javascript target will not work in a browser environment.

gleam add casper@1
import casper
import gleam/crypto

pub fn main() -> Nil {
  // Generate a 32 byte encryption key
  let key = crypto.strong_random_bytes(32)

  // This will fail if the key isn't the right size, i.e. 32 bytes
  let assert Ok(encrypted) = casper.encrypt(<<"casper">>, key)

  // This can fail if the encrypted content isn't in the right format
  let assert Ok(decryted) = casper.decrypt(encrypted, key)

  // ...
}

Further documentation can be found at https://hexdocs.pm/casper.

Development

gleam run   # Run the project
gleam test  # Run the tests on Erlang
gleam test -t javascript # Run the tests on Node
Search Document