codelockr: A Versatile JavaScript/Typescript Cryptography Library
npm install codelockrThis JavaScript/Typescript library, codelockr, empowers you to explore and implement a wide range of classical ciphers directly within your web applications. It provides user-friendly functions for various encryption and decryption techniques, making it an ideal tool for:
To install codelockr in your project, use either npm or yarn:
npm install codelockr
or
yarn add codelockr
codelockr offers a rich set of cipher implementations, each with its own encryption methods. Here's a table outlining the supported ciphers and how to use them:
| Cipher | Description | Import Statement | Encryption Method |
|---|---|---|---|
| Caesar Cipher | Shifts plaintext letters by a specified number of positions. | import { CaesarCipher } from 'codelockr'; |
CaesarCipher(plaintext, shift) |
| Rail Fence Cipher | Encrypts by writing across a specified number of rows (rails) and reading down. | import { RailFenceCipher } from 'codelockr'; |
RailFenceCipher(plaintext, rails) |
| Substitution Cipher | Replaces plaintext letters with a custom mapping defined in a substitution key. | import { SubstitutionCipher } from 'codelockr'; |
SubstitutionCipher(plaintext, substitutionKey) |
| Atbash Cipher | Reverses the alphabet (A maps to Z, B maps to Y, etc.). | import { AtbashCipher } from 'codelockr'; |
AtbashCipher(plaintext) |
| Beaufort Cipher | Combines Caesar ciphers with a keyword for a more complex encryption. | import { BeaufortCipher } from 'codelockr'; |
BeaufortCipher(plaintext, keyword) |
| Autokey Cipher | Uses the plaintext itself as a keystream, where each letter's shift is based on the previous ciphertext letter. | import { AutokeyCipher } from 'codelockr'; |
AutokeyCipher(plaintext, keyword) |
| Columnar Transposition | Rearranges letters based on a permutation order defined in a key. | import { ColumnarTranspositionCipher } from 'codelockr'; |
ColumnarTranspositionCipher(plaintext, columnarTranspositionKey) |
| Vigenere Cipher | Uses a repeating keyword to shift letters by varying amounts. | import { VigenereCipher } from 'codelockr'; |
VigenereCipher(plaintext, keyword) |
| Playfair Cipher | Creates a bigram square based on a key and encrypts letter pairs. | import { PlayfairCipher } from 'codelockr'; |
PlayfairCipher(plaintext, keyword) |
| Polybius Square Cipher | Assigns numbers (1-25) to letters in a 5x5 grid for encryption/decryption. | import { PolybiusSquareCipher } from 'codelockr'; |
PolybiusSquareCipher(plaintext) |