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.
Using the cipher, strings can be encypted. When the cipher and encrypted string is given it possible to decrypt the encrypted text.
CONSTANT = 'abcdefghijklmnopqrstuvwxyz' cipher = 'zodvqukgwefbyitmrsplhacxnj' encrypted text = 'dzs' original text = 'car'
CONSTANT = 'abcdefghijklmnopqrstuvwxyz' cipher = 'xipmuzfkbrlwotjancqgveshdy' encrypted text = 'skd qj qucbjvq?' original text = 'why so serious?'
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.
- Add test/spec to your solution.
Time: 30 mins