tannerdolby / rotation-cipher

Utility for creating caesar ciphers.

Home Page:https://www.npmjs.com/package/rotation-cipher

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Rotation Cipher 🗝️

A lightweight utility for performing caesar ciphers. This classic cipher shifts characters in a given string by a specified amount to provide a small layer of encryption.

Capable of creating ciphers containing characters in the english alphabet (a-zA-Z) and human-readable ASCII characters.

Use cases:

  • perform basic, custom, and randomized caesar ciphers
  • generate a cool username / social media handle

Installation

Install the package from npm:

npm install rotation-cipher

Create ciphers on the fly:

import { caesarCipher } from 'rotation-cipher';

console.log(caesarCipher('tanner', 21));
// oviizm

Example usage

Basic Cipher

Rotate each character by the default 13 characters:

console.log(caesarCipher('tanner'));
// gnaare

User defined uniform rotation

Rotate each character by a uniform rotation:

console.log(caesarCipher('tanner', 17));
// kreevi

User defined uniform rotation (with ASCII)

Rotate each character by a uniform rotation including ASCII:

console.log(caesarCipher('t@nn3r!', 15));
// i,cc}g0

Custom rotation array

Rotate each character by a specific rotation:

console.log(caesarCipher('tanner', 0, [3, 5, 1, 2, 7, 8]));
// wfoplz

Random rotation

Rotate each character by a random rotation:

import { caesarCipher, randomRotation } from 'rotation-cipher';

let s = 'tanner';
console.log(caesarCipher(s, 0, randomRotation(s)));

Resources

About

Utility for creating caesar ciphers.

https://www.npmjs.com/package/rotation-cipher


Languages

Language:TypeScript 55.3%Language:JavaScript 44.7%