Skip to content

jbenet/js-senc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

js-senc - js implementation of senc

Library

WARNING: Library uses pull-streams.

Works in node.js and the browser. Uses libp2p-crypto.

Install

npm install --save senc

Encrypt

var senc = require('senc')
var stdio = require('pull-stdio')
var key = senc.RandomKey()

pull(
  stdio.stdin({encoding: binary}),
  senc.EncryptStream(key),
  stdio.stdout(() => {})
)

Decrypt

var senc = require('senc')
var stdio = require('pull-stdio')
var key = <key-from-above>

pull(
  stdio.stdin({encoding: binary}),
  senc.DecryptStream(key),
  stdio.stdout(() => {})
)

Random Key

var senc = require('senc')
console.log(senc.RandomKey())

Command Line

Install

npm install --global senc

Usage

usage:  senc  -e -k <key> - encrypt stdin with aes
        senc  -d -k <key> - decrypt stdin with aes

OPTIONS
  -h, --help    this help text
  -d            set decrypt mode
  -e            set encrypt mode
  -k <string>   key to use (in multibase)
  -b <base>     the multibase encoding to write key to
  --key-gen     generate a key

Key-gen

> senc --key-gen
zEkHKdVKVUazjMndot4puCyA57Ji7vH6VhemsNk8vvkhi

> key=$(senc --key-gen)

Encrypt

senc -k zEkHKdVKVUazjMndot4puCyA57Ji7vH6VhemsNk8vvkhi -e <plaintext >ciphertext

Decrypt

senc -k zEkHKdVKVUazjMndot4puCyA57Ji7vH6VhemsNk8vvkhi -d <ciphertext >plaintext2

Full Example

# keygen
senckey=$(senc --key-gen)

# encrypt
senc -k $senckey -e <plaintext >ciphertext

# decrypt
senc -k $senckey -d <ciphertext >plaintext2

# check the diff
diff plaintext plaintext2

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published