1.0.4 • Published 3 years ago

chao v1.0.4

Weekly downloads
4
License
UNLICENSED
Repository
github
Last release
3 years ago

Chao

A Javascript implementation of the Chaocipher.

How it works

Chaocipher was discovered by John F. Byrne, an associate of James Joyce, in 1918. It's a type of dynamic substitution cipher where the starting input and output alphabet are scrambled after each step. While difficult to decrypt by hand, it's known to have been broken by known plaintext attack.

The "key" for this algorithm is the initial input and output alphabets. Each alphabet should contain a permutation of the all the characters that you want in your input and output. Any characters not in the alphabet will be left alone.

To install:

npm install chao

Usage example:

const Chaocipher = require('chao')
const assert = require('assert')

const plaintextAlphabet = 'df6nCwtk0F7NoQ4prO1aR5Hcq3xJSMiYB9eVWTL8XAslEzuhmUbygIvKPZDG2j'
const ciphertextAlphabet = 'CLMYN3KWOX6bPEQRgqtn0J4IruH5Bcfv9jkGhm1ZSzyA78iUFwT2slpDaVxedo'

const chao = new Chaocipher(plaintextAlphabet, ciphertextAlphabet)

const input = 'Something very important!'
const ciphertext = chao.encode(input)
assert.equal(ciphertext, 'X2VP4Y8oF qUNj MqsQlBCdf!')
const recoveredtext = chao.decode(ciphertext)
assert.equal(recoveredtext, input)

The code is largely based on https://github.com/aprescott/chaocipher

1.0.4

3 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago