I'm studying mathematical cryptography and have been asked to find the encryption function for the Atbash cipher I know that it means a=z, b=y, c=x and so on but putting it into a formula has me a bit stuck. I already know affine ciphers version of the atbash is $ -(x+1) mod m $

Any help would be greatly appreciated! Thanks


The math goes: add the integer assigned to a, the integer assigned to z, and from that constant (which can be pre-computed) subtract the integer assigned to the letter to encode; that gives the integer assigned to the encoded letter.

This works for a to z and encodings with consecurive letters of the alphabet assigned consecutive integer values (including ASCII; assigning 0 to a and 25 to z; assigning 1 to a and 26 to z). Usual associativity and commutativity rules for addition in $\mathbb Z$ are enough to prove that a is encoded to z, and vice versa. The rest follows by uh, intuition? Or induction if we really strive for rigor.

In C, that gives

char Atbash(char x) {
  return ('a'+'z')-x;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.