rotation-cipher
TypeScript icon, indicating that this package has built-in type declarations

1.2.2 • Public • Published

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

Package Sidebar

Install

npm i rotation-cipher

Weekly Downloads

1

Version

1.2.2

License

ISC

Unpacked Size

17.9 kB

Total Files

9

Last publish

Collaborators

  • tannerdolby