Ever wondered how ciphers really work under the hood? cipher-utils lets you explore three classic encryption algorithms - ROT13, Base64, and XOR cipher - implemented purely in JavaScript, with zero dependencies and no complex regex patterns.
npm install cipher-utils
Import specific functions or grab the entire package:
// Pick what you need
import { rot13, encode, decode, encrypt, decrypt } from 'cipher-utils';
// Or import everything
import CipherUtils from 'cipher-utils';
const { rot13, encode, decode, encrypt, decrypt } = CipherUtils;
ROT13 shifts each letter 13 positions in the alphabet. Run it twice and you're back to square one!
import { rot13 } from 'cipher-utils';
const text = 'Hello, World!';
console.log(rot13(text)); // Output: Uryyb, Jbeyq!
console.log(rot13('Uryyb, Jbeyq!')); // Back to: Hello, World!
No Buffer magic here! Just pure JavaScript implementation of Base64 encoding:
import { encode, decode } from 'cipher-utils';
const text = 'Hello, World!';
console.log(encode(text)); // Output: SGVsbG8sIFdvcmxkIQ==
console.log(decode('SGVsbG8sIFdvcmxkIQ==')); // Back to: Hello, World!
// Short strings get padding:
console.log(encode('Test')); // Output: VGVzdA==
Perfect for casual obfuscation (not Fort Knox level security!). Use the same key to encrypt and decrypt:
import { encrypt, decrypt } from 'cipher-utils';
const message = 'Secret message';
const key = 'my_secret_key';
const encrypted = encrypt(message, key);
console.log(encrypted); // Hex string
const decrypted = decrypt(encrypted, key);
console.log(decrypted); // Back to: Secret message
rot13(inputString)
→ Returns ROT13 transformed stringencode(inputString)
→ Returns Base64 encoded stringdecode(base64String)
→ Returns decoded stringencrypt(inputString, key)
→ Returns hex-encoded encrypted stringdecrypt(hexInput, key)
→ Returns decrypted string
- Zero dependencies keeps your project lean
- No regex complexity to deal with
- Pure JavaScript implementation you can easily understand
- Great for learning how ciphers actually work
- Perfect for educational projects or simple encryption needs
Fork the repository. Create a feature branchAdd tests for your changes. Submit a pull request.
MIT Licensed - feel free to use and modify as needed.