Skip to content

carlstoker/classical_ciphers

Repository files navigation

Classical Ciphers

A collection of ciphers from the classical era. Inspired by Practical Cryptography.

Unless otherwise noted, the default alphabets for these ciphers is the lowercase English alphabet.

Affine Cipher

A monoalphabetic substitution cipher.

key_a and the length of the alphabet (26 by default) must be coprime.

Example

from affine import Affine
key_a = 7
key_b = 9
a = Affine(key_a, key_b)

Atbash Cipher

The Atbash cipher is a version of the Affine cipher, using 25 as both key_a and key_b

from atbash import Atbash
a = Atbash()

Caesar Cipher

A simple substitution cipher using a shift of 3.

Example

from caesar import Caesar
c = Caesar()

Gronsfeld Cipher

A variant of the Vigenère cipher which uses numbers instead of letters for the key.

Example

from gronsfeld import Gronsfeld
key = [1, 2, 3, 4, 5]
g = Gronsfeld(key)

ROT13 Cipher

A simple substitution cipher using a shift of 13.

Example

from rot13 import Rot13
r = Rot13()

A variant of the Vigenère cipher where the key must be longer than the plaintext.

Example

from runningkey import RunningKey
key = "itwasthebestoftimesitwastheworstoftimes"
r = RunningKey(key)

A monoalphabetic substitution cipher which shifts the plaintext by the specified shift parameter.

Example

from substitution import Substitution
shift_value = 5
s = Substitution(shift_value)

Vigenère Cipher

A monoalphabetic substitution cipher which shifts the plaintext by the specified shift parameter.

Example

from vigenere import Vigenere
key = "foobar"
v = Vigenere(key)

About

Classical ciphers implemented in python

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages