Skip to content

Instantly share code, notes, and snippets.

@hapiben
Last active July 12, 2016 21:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save hapiben/851e247979b33c9897077436d43e7a4a to your computer and use it in GitHub Desktop.
Save hapiben/851e247979b33c9897077436d43e7a4a to your computer and use it in GitHub Desktop.

Atbash is a simple substitution cipher possible with any known alphabet. It emerged around 500-600 BCE. It works by substituting the letters of an alphabet with another.

English alphabets in order is the constant.

CONSTANT = 'abcdefghijklmnopqrstuvwxyz'

A random shuffle of the constant is the ciper.

Example cipher: zyxwvutsrqponmlkjihgfedcba

Using the cipher, strings can be encypted. When the cipher and encrypted text is given it possible to decrypt the encrypted text.

Example 1

CONSTANT       = 'abcdefghijklmnopqrstuvwxyz'
cipher         = 'zodvqukgwefbyitmrsplhacxnj'
encrypted text = 'dzs'
original text  = 'car'

Example 2

CONSTANT       = 'abcdefghijklmnopqrstuvwxyz'
cipher         = 'xipmuzfkbrlwotjancqgveshdy'
encrypted text = 'skd qj qucbjvq?'
original text  = 'why so serious?'

The challenge

CONSTANT       = 'abcdefghijklmnopqrstuvwxyz'
cipher         = 'oephjizkxdawubnytvfglqsrcm'
encrypted text = 'knlfgnb, sj koqj o yvnewju'
original text  = ?

Decrypt the given encrypted text. Any character other than what you have in the constant doesn't have to be replaced.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment