A type of monoalphabetic substitution cipher, wherein each letter in an alphabet is mapped to its numeric equivalent, encrypted using a simple function `(ax + b) mod m`.

The affine cipher is a type of monoalphabetic substitution cipher, wherein each letter in an alphabet is mapped to its numeric equivalent, encrypted using a simple mathematical function, and converted back to a letter. The formula used means that each letter encrypts to one other letter, and back again, meaning the cipher is essentially a standard substitution cipher with a rule governing which letter goes to which. As such, it has the weaknesses of all substitution ciphers.

Each letter is enciphered with the function (ax + b) mod m, where b is the magnitude of the shift, and m is the length of alphabet. a has to be coprime to m in order for decryption to be possible.

Caesar's cipher is a most known example of affine cyphers, with formula (x + b) mod 26.

https://en.wikipedia.org/wiki/Affine_cipher