enkodo

A cross platform encyption and serialization library


Keywords
monocypher, encryption, javascript
License
MIT
Install
nimble install enkodo

Documentation

Gitpod Ready-to-Code

enkōdo

Enkodo is a cross platform encyption and serialization wrapper for monocypher written in nim, with compatibility targets in typescript and more planned in the future.

Building all targets

These are the nim instructions and what they do:

nimble buildall #creates all the libraries and helpers for all languages 

Usage

Nim

Below is a simple nim example of encypting, serializing and base64ing

import enkodo

let (a_secretKey, a_publicKey) = generateKeyPair()
let (b_secretKey, b_publicKey) = generateKeyPair()

let plaintext = cast[seq[byte]]("hello this is a test string")

let encObj = enc(a_secretKey,b_publicKey,plaintext)
let wrapped = wrap(encObj)
let unwrapped = unwrap(wrapped)
let ptext = dec(b_secretKey,unwrapped)
doAssert(plaintext == ptext)

Typescript

Below is a simple nim example of encypting, serializing and base64ing

import {
  enc,
  dec,
  generateKeyPair,
  unwrap,
  wrap
} from "https://deno.land/x/enkodo@v0.1.2/typescript/mod.ts";

const hello_world = new TextEncoder().encode("Hello World");
const [priv, pub] = generateKeyPair();
const [priv2, pub2] = generateKeyPair();

const enc_test = enc(priv, pub2, hello_world);
const plain = dec(priv2, enc_test);
assertEquals(hello_world, plain);

Nimble Test

Tests the encryption and serialization functions

nimble test 

Deno Test

Tests the encryption functions

deno test 
deno bench #runs the benchmark

Planned compatibility