✘ - - - DECIPHER is a book compilation that tackles different, new and old codes/ciphers. In addition, this book begins with the definition of cryptography along with it's different terminology for begginers, and better understanding.
Interested? W...
‣ Affine Cipher is a type of monoalphabetic substitution cipher, where each letter in an alphabet is mapped to its numeric equivalent, encrypted using a simple mathematical function, and converted back to a letter.
The whole process relies on working modulo m or the length of the alphabet used. By performing a calculation on the plaintext letters, we encipher the plaintext. Each letter is enciphered with the function (ax + b) mod 26, where b is the magnitude of the shift.
So, A becomes 0, B becomes 1 and Z becomes 25. If encoding use the common function (ax+b) mod 26.
Encryption:
↳ The encryption key for an affine cipher is an ordered pair of integers, both of which come from the set {0, . . . , m − 1}, where m is the size of the character set being used (In this case, the character set is the English alphabet, so we have m = 26).It is important to note that some of the possible pairs of integers from the set {0, . . . , m − 1} are not valid as affine encryption keys.
What other values of α cannot be used? It turns out that if α has a factor other than ±1 in common with 26, then it is not a valid choice for an encryption key. The valid encryption keys (for a 26-letter character set) are of the form (α, β), where α, β ∈ {0, 1, . . . , 25} and gcd (α, 26) = 1. α must have a gcd of 1 with 26, so must be one of the following numbers: 1, 3, 5, 7, 9, 11, 15, 17, 19, 21, 23, 25. As β can be any of the numbers 0, 1, . . . , 25.
↳ To describe the encryption, we again consider the following conversion table for the English alphabet.
Oops! This image does not follow our content guidelines. To continue publishing, please remove it or upload a different image.
Suppose we want to encrypt the message "Love" using an affine cipher with encryption key (5, 1).
I. Using the table, we can represent the letters in our message "Love" with their corresponding num- bers which is: 11 14 21 4
II. Now we multiply each of the numbers from step I by the first number in our encryption key which is 5 to get: 55 70 105 20
III. Next, add the second number in our encryption key which is 1 to each of the numbers from step II to get: 56 71 106 22.
IV. Now use the table to replace the numbers from step III with their corresponding letters to obtain the ciphertext.
So LOVE = E T B W
As with shift ciphers, there is a small complication when the arithmetic we do in steps II and II above produces a number that is larger than 25.
Now, how to fix this?
If the number is greater than 25 like 56 simply subtract 26 from it (modulo 26) until it is lower than 25. Like what I did in the example above.
Other example:
Encryption of the plaintext "Affine" using an affine cipher with encryption key (3, 1) produces ciphertext "BQQZON" this way:
A - 0 - x3 - 0 - +1 - 1 = B F - 5 - x3 - 15- +1 - 16 = Q F - 5 - x3 - 15 - +1- 16= Q I - 8 - x3 - 24 -+1- 25 = Z N-13 -x3-39-+1- 40 - 26 ~ 14 = O E - 4 - x3 - 12 - +1 - 13 = N
Challenge:
Create your own encryption with an encryption key (5, 7)
***
Ps. I somewhat showed it the way I understand this cipher, so if ever it has errors and corrections. Let me know.
Pps. Ito muna sa ngayon. Ang sakit pa ng brain cells ko sa decryption method niya. Nakakaloka. Will publish it, if na gets ko na. :/