15937823 / cipherjs

Javascript Implementation of simple Ciphers

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Build Status Coverage Status Downloads Version

Javascript implementation of simple Ciphers


CipherJS CLI Demo

Installation

Install the package using yarn:

$ yarn add cipherjs

or npm:

$ npm install --save cipherjs

Usage

Start by require-ing the module:

const CipherJS = require('cipherjs');

It returns an Object of available ciphers, each with their own encrypt and decrypt methods:

CipherJS.Vigenere.encrypt('MY SECRET MESSAGE', 'MY SECRET KEY')
// YW KIEIIM WIQEYYI

Command-line App

cipherjs comes with a CLI app that lets you encrypt or decrypt data interactively. To use it, install the package globally:

$ npm install -g cipherjs

and just execute cipherjs in your terminal:

$ cipherjs

Ciphers

All Ciphers have one encrypt and decrypt method, with the first argument as the ciphertext / plaintext.

Affine Cipher

Takes two numeric keys, the first of which should be a coprime with 26 and the second should be between 0-25:

CipherJS.Affine.encrypt('AFFINE CIPHER', 5, 23)
// 'XWWLKR HLUGRE'

CipherJS.Affine.decrypt('XWWLKR HLUGRE', 5, 23)
// 'AFFINE CIPHER'

Caesar Cipher

Takes one numeric key along with the plaintext / ciphertext:

CipherJS.Caesar.encrypt('CAESAR CIPHER', 13)
// 'PNRFNE PVCURE'

CipherJS.Caesar.decrypt('PNRFNE PVCURE', 13)
// 'CAESAR CIPHER'

Simple Substitution Cipher

Takes only a string key for encoding and decoding:

CipherJS.Substitution.encrypt('SIMPLE SUBSTITUTION CIPHER', 'SECRET KEY')
// 'OBHLGT OQEOPBPQPBJI CBLATN'

CipherJS.Substitution.decrypt('OBHLGT OQEOPBPQPBJI CBLATN', 'SECRET KEY')
// 'SIMPLE SUBSTITUTION CIPHER'

Vigenere Cipher

Takes only a string key for encoding and decoding:

CipherJS.Vigenere.encrypt('VIGENERE CIPHER', 'ANOTHER SECRET KEY')
// 'VVUXUIIW GKGLXB'

CipherJS.Vigenere.decrypt('VVUXUIIW GKGLXB', 'ANOTHER SECRET KEY')
// 'VIGENERE CIPHER'

Contributing

  • Fork, Enhance, Send PR
  • Lock issues with any bugs or feature requests
  • Implement something from Roadmap
  • Spread the word

License

This package is available as open source under the terms of the MIT License.


About

Javascript Implementation of simple Ciphers

License:MIT License


Languages

Language:JavaScript 100.0%