https://github.com/sheharyarn/cipherjs
Javascript Implementation of simple Ciphers
https://github.com/sheharyarn/cipherjs
ciphers cli cryptography decryption encryption hacktoberfest javascript npm-package
Last synced: 11 months ago
JSON representation
Javascript Implementation of simple Ciphers
- Host: GitHub
- URL: https://github.com/sheharyarn/cipherjs
- Owner: sheharyarn
- License: mit
- Created: 2017-02-13T06:32:08.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2022-12-06T20:38:41.000Z (over 3 years ago)
- Last Synced: 2025-06-12T01:04:42.227Z (about 1 year ago)
- Topics: ciphers, cli, cryptography, decryption, encryption, hacktoberfest, javascript, npm-package
- Language: JavaScript
- Homepage:
- Size: 628 KB
- Stars: 12
- Watchers: 2
- Forks: 3
- Open Issues: 13
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[
][github-repo]
=========================================================
[![Build Status][shield-travis]][travis]
[![Coverage Status][shield-coveralls]][coveralls]
[![Downloads][shield-downloads]][npm]
[![Version][shield-version]][npm]
> Javascript implementation of simple Ciphers
![CipherJS CLI Demo][cli-demo]
## Installation
Install the package using `yarn`:
```bash
$ yarn add cipherjs
```
or `npm`:
```bash
$ npm install --save cipherjs
```
## Usage
Start by `require`-ing the module:
```js
const CipherJS = require('cipherjs');
```
It returns an `Object` of available ciphers, each with their own `encrypt` and
`decrypt` methods:
```js
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:
```bash
$ npm install -g cipherjs
```
and just execute `cipherjs` in your terminal:
```bash
$ 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`:
```js
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:
```js
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:
```js
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:
```js
CipherJS.Vigenere.encrypt('VIGENERE CIPHER', 'ANOTHER SECRET KEY')
// 'VVUXUIIW GKGLXB'
CipherJS.Vigenere.decrypt('VVUXUIIW GKGLXB', 'ANOTHER SECRET KEY')
// 'VIGENERE CIPHER'
```
## Contributing
- [Fork][github-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][github-license].
[logo]: media/logo.png
[cli-demo]: media/cli.gif
[npm]: https://www.npmjs.com/package/cipherjs
[travis]: https://travis-ci.org/sheharyarn/cipherjs
[coveralls]: https://coveralls.io/github/sheharyarn/cipherjs
[github-repo]: https://github.com/sheharyarn/cipherjs
[github-fork]: https://github.com/sheharyarn/cipherjs/fork
[github-license]: https://github.com/sheharyarn/cipherjs/blob/master/LICENSE
[shield-travis]: https://img.shields.io/travis/sheharyarn/cipherjs.svg
[shield-coveralls]: https://img.shields.io/coveralls/sheharyarn/cipherjs.svg
[shield-downloads]: https://img.shields.io/npm/dt/cipherjs.svg
[shield-version]: https://img.shields.io/npm/v/cipherjs.svg