# perchi

> Implementation of classical ciphers.

Latest version **1.1.0** (published 2026-08-13) · ISC license · 0 weekly downloads

## Install

```sh
npm install perchi
pnpm add perchi
yarn add perchi
bun add perchi
```

## Health

**Score 45/100 (D)** — status: active.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2026-08-13 |
| First published | 2022-01-11 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=12 |
| Dependencies | 0 |
| Unpacked size | 44.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Kamil Popczyk |
| Maintainers | kpopc |
| Keywords | cipher, vigenre, atbash, cryptography, perchi, javascript, node, caesar, encryption, decryption |

## Links

- npm: https://www.npmjs.com/package/perchi
- Repository: https://github.com/bypopdev/perchi
- Homepage: https://github.com/bypopdev/perchi#readme
- Issues: https://github.com/bypopdev/perchi/issues
- npm.io page: https://npm.io/package/perchi

## Alternatives

- [@gemini-wallet/core](https://npm.io/package/@gemini-wallet/core.md) — 515.6K weekly downloads
- [utility](https://npm.io/package/utility.md) — 416.6K weekly downloads
- [@primno/dpapi](https://npm.io/package/@primno/dpapi.md) — 7.2K weekly downloads
- [pi-readseek](https://npm.io/package/pi-readseek.md) — 3.7K weekly downloads
- [@emilia-protocol/verify](https://npm.io/package/@emilia-protocol/verify.md) — 1.1K weekly downloads

## Recent versions

- 1.1.0 (latest) — 2026-08-13
- 1.0.4 — 2022-05-24
- 1.0.3 — 2022-01-11
- 1.0.2 — 2022-01-11
- 1.0.1 — 2022-01-11
- 1.0.0 — 2022-01-11

## README

# perchi

<br/>

perchi is the implementation of ciphers like Caesar or Vigenère in JavaScript.

Name 'perchi' is anagram: **'perchi' = 'cipher'**

## Install

```
$ npm install perchi
```

<br/>

## Available ciphers

- CaesarCipher
- VigenereCipher
- AtbashCipher
- BaconCipher
- RailFenceCipher
- AffineCipher
- PlayfairCipher
- ColumnarTranspositionCipher

## Usage

You can use the perchi by`import`-ing the module:

```js
import CaesarCipher from "perchi";
```

or use `require`:

```js
const { CaesarCipher } = require("perchi");
```

It returns collections of utility `classes`. Each cipher implementation has `encrypt` and `decrypt` methods which are synchronous. For large input, use `encryptAsync` and `decryptAsync`; they run in a Node.js worker thread and return a `Promise`. Some of ciphers has implemented `breakCipher` functions that break the code for example by brute-force atack. By default ciphers implementations use the following alphabet: `ABCDEFGHIJKLMNOPQRSTUVWXYZ`.

Example of Caesar cipher with left shift of 3:

```js
CaesarCipher.encrypt("perchi is cool", -3);
// mbozef fp zlli

CaesarCipher.decrypt("mbozef fp zlli", -3);
// perchi is cool
```

Example of Atbash cipher with custom alphabet:

```js
const polishAlphabet = "aąbcćdeęfghijklłmnńoóprsśtuwyzźż";

AtbashCipher.encrypt("Zażółć gęślą jaźń", polishAlphabet);
// Bżaimw rśęnź ożąk

AtbashCipher.decrypt("Bżaimw rśęnź ożąk", polishAlphabet);
// Zażółć gęślą jaźń
```

## Additional ciphers

All ciphers in this package are educational classical ciphers, not secure encryption.

```js
const {
  RailFenceCipher,
  AffineCipher,
  PlayfairCipher,
  ColumnarTranspositionCipher,
} = require("perchi");

RailFenceCipher.encrypt("WEAREDISCOVEREDFLEEATONCE", 3);
// WECRLTEERDSOEEFEAOCAIVDEN

AffineCipher.encrypt("AFFINE CIPHER", 5, 8);
// IHHWVC SWFRCP

PlayfairCipher.encrypt("HIDETHEGOLDINTHETREESTUMP", "PLAYFAIR EXAMPLE");
// BMODZBXDNABEKUDMUIXMMOUVIF

ColumnarTranspositionCipher.encrypt("WEAREDISCOVEREDFLEEATONCE", "ZEBRAS");
// EVLNACDTESEAROFODEECWIREE
```

`RailFenceCipher` takes an integer rail count. `AffineCipher` takes a multiplier that must be coprime with the alphabet length and a shift. `ColumnarTranspositionCipher` preserves every input character and uses a non-empty key.

`PlayfairCipher` uses the standard 25-letter alphabet (`I` and `J` share a position), converts text to uppercase, ignores unsupported characters, and inserts `X` filler symbols for repeated or trailing letters. Decryption retains those filler symbols because it cannot reliably distinguish them from real `X` characters.

## Async performance

Run the reproducible benchmark with:

```sh
npm run benchmark:async
```

The asynchronous methods use a Node.js worker thread. This keeps the main event loop available, but a newly created worker has startup and message-transfer overhead. On Node.js v24.16.0, arm64 with 15 logical CPU cores, using a 5 MiB Caesar input and five samples, the median results were:

| Operation | Median time |
| --- | ---: |
| Synchronous completion | 253.4 ms |
| Async dispatch to worker | 0.4 ms |
| Async completion | 292.5 ms |

In every sample the event loop completed a `setImmediate` turn before the asynchronous cipher completed. Use `encryptAsync` and `decryptAsync` when main-thread responsiveness matters; use the synchronous methods for small inputs or when lowest completion latency matters.

## License

ISC © [bypopdev](https://github.com/bypopdev)

---
_Source: https://npm.io/package/perchi · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
