---
title: "Porta"
description: "Thirteen tables for 26 key letters. A to M always swaps with N to Z. One call encodes and decodes."
canonical_url: "https://ciphers.agntn.dev/ciphers/porta"
---
# Porta

> Thirteen tables for 26 key letters. A to M always swaps with N to Z. One call encodes and decodes.

<cipher-facts name="porta">



</cipher-facts>

Giambattista della Porta printed this one in 1563. Each key letter picks one of 13 tables. A and B share the first, C and D the second, and so on up to Y and Z. Every table swaps the two halves of the alphabet. A to M goes to N to Z and back again. So `encode` and `decode` are the same call, like [Beaufort](https://ciphers.agntn.dev/ciphers/beaufort).

```ts
const porta = create("porta");
const key = { key: "FORTIFICATION" };
porta.encode("DEFENDTHEEASTWALLOFTHECASTLE", key).text;
// "SYNNJSCVRNRLAHUTUKUCVRYRLANY"
porta.encode("SYNNJSCVRN", key).text; // "DEFENDTHEE", same call back
```

That's the worked example from [Practical Cryptography](http://practicalcryptography.com/ciphers/porta-cipher/), which uses the ACA table.

## Which way does it turn?

Here's the catch. Nobody agrees which way the N to Z half moves from table to table. The ACA, Gaines and Practical Cryptography turn it left, so C and D give `OPQ…`. dCode turns it right by default, so C and D give `ZNO…`. Same key, same text, two ciphertexts. Both stay reciprocal, so the wrong one doesn't fail. It just hands you noise.

`rotation` picks the side, `left` by default or `right`:

```ts
porta.encode("DCODE", { key: "PORTA", rotation: "right" }).text; // "WVJUR", dCode's example
porta.encode("DCODE", { key: "PORTA" }).text; // "XWGZR", the ACA table
```

Got a Porta from dCode that reads like soup? Flip `rotation` before you blame the key.

## The rest of the text

Only ASCII letters move the key along. Spaces, punctuation and emoji pass through. Lowercase stays lowercase unless `preserveCase` is false, and `stripNonAlpha` drops everything outside A to Z first. The key ignores case and anything that isn't a letter. No key is a `MissingOptionError`, and a key without letters an `InvalidOptionError`.

## Why it's weak

Thirteen tables, not 26. F and E pick the same one, so `FORT` and `EPQS` are the same key. A key of n letters has 2^n spellings, and FORTIFICATION alone has 8,192.

Worse, a letter never stays in its half. E can't come out as H, so `HEP` is never `THE`. That's a free filter for every crib you try. The key still repeats too, so [`period`](https://ciphers.agntn.dev/guide/analysis) finds its length the same way it does for Vigenère. Handy on paper, one table for both ways. That's about all it has going for it.


## Sitemap

See the full [sitemap](https://ciphers.agntn.dev/sitemap.md) for all pages.
