npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

classical-ciphers

v1.0.0

Published

Tiny dependency-free TypeScript implementations of the classic ciphers: Caesar/ROT13/ROT47, Vigenère/Autokey/Beaufort, and Atbash. Case-preserving, total over arbitrary text.

Readme

classical-ciphers

test license: MIT

Tiny, dependency-free TypeScript implementations of the classic pen-and-paper ciphers — Caesar / ROT13 / ROT47, Vigenère / Autokey / Beaufort, and Atbash.

Every transform preserves letter case and passes non-letters (digits, spaces, punctuation, other scripts) through untouched, so each function is a total function over arbitrary text — safe to run over a whole document without mangling its shape.

🔐 Prefer an interactive version? Each cipher here has a free in-browser tool at textmachine.org — paste text, tweak the key, and copy the result. No sign-up, nothing leaves your device: Caesar / ROT · Vigenère · Atbash

🔎 Not sure which cipher you're looking at? Paste it into the Cipher Identifier — it analyses the text (letter frequency, Index of Coincidence, χ² shift tests) and ranks the likely ciphers, each with a one-click link to its decoder.

Install

npm install classical-ciphers

Usage

import {
  caesarShift, caesarEncode, caesarDecode, rot47, rotateDigits,
  applyVigenere,
  atbash,
} from "classical-ciphers";

// Caesar — shift within each case, punctuation untouched
caesarEncode("Hello, World!", 3);   // "Khoor, Zruog!"
caesarDecode("Khoor, Zruog!", 3);   // "Hello, World!"

// ROT13 is just a shift of 13 — and its own inverse
caesarShift("Attack at dawn", 13);  // "Nggnpx ng qnja"

// ROT47 over printable ASCII (also self-inverse)
rot47("Hello");                      // "w6==@"

// ROT5 over the digits 0–9
rotateDigits("Order 2026", 5);       // "Order 7571"

// Vigenère — a repeating keyword supplies a different shift per letter
applyVigenere("ATTACKATDAWN", "LEMON", "vigenere", "encode"); // "LXFOPVEFRNHR"
applyVigenere("LXFOPVEFRNHR", "LEMON", "vigenere", "decode"); // "ATTACKATDAWN"

// Autokey (key never repeats) and Beaufort (reciprocal — decode === encode)
applyVigenere("ATTACKATDAWN", "LEMON", "autokey",  "encode"); // "LXFOPKTMDCGN"
applyVigenere("ATTACKATDAWN", "LEMON", "beaufort", "encode"); // run again to decode

// Atbash — A↔Z mirror, self-inverse
atbash("Hello, World!");             // "Svool, Dliow!"

API

| Function | Signature | Notes | | --- | --- | --- | | caesarShift | (text, shift) => string | Rotate letters by shift (mod 26; negative/large normalised). | | caesarEncode / caesarDecode | (text, shift) => string | Convenience wrappers (decode = shift by -shift). | | rotateDigits | (text, shift) => string | ROT-N over the digits 0–9 only. | | rot47 | (text) => string | Rotate printable ASCII (33–126) by 47; self-inverse. | | applyCipher | (text, cipher, direction) => string | Dispatch {kind:"caesar",shift} | {kind:"rot5"} | {kind:"rot47"}. | | normalizeKey | (key) => number[] | Reduce a keyword to its A–Z letters as 0–25. | | applyVigenere | (text, key, variant, direction) => string | variant: "vigenere" | "autokey" | "beaufort". Empty/letterless key = identity. | | atbash | (text) => string | A↔Z mirror; self-inverse. |

Types Cipher, Direction ("encode" | "decode") and Variant are exported.

Design notes

  • No dependencies, no side effects — pure string→string functions.
  • Case-preserving and total — non-A–Z characters are emitted unchanged and, for Vigenère, do not advance the keystream, so message structure survives.
  • Self-inverse ciphers (ROT13, ROT47, Atbash, Beaufort) use the same call to encode and decode.
  • These ciphers are of historical / educational interest and are not secure — don't use them to protect real secrets.

License

MIT © 2026 Text Machine — built alongside the free text tools at textmachine.org.