This is made to serve as a reviewer. All the information and images are not mine.To know more about the codes please visit the page of Watson's Swordcane on facebook.
Watson's Sworcane link:
↪https://www.facebook.com/WatsonsSwordcane/
The Affine cipher is an example of a monoalphabetic substitution cipher, wherein, each letter in the alphabet were mapped to its numeric equivalent, encrypted using a simple mathematical function and converted back to a letter which means that the Affine cipher is essentially a standard substitution cipher with a rule governing which letter goes to which.
[ENCRYPTION] The first step of the encryption is to transform each letters of the plaintext alphabet to the corresponding integer in the range 0 to m−1 and so on. With this done, the encryption process for each letter is given by this formula: 𝐄(𝒙)=(𝒂𝒙+𝒃) mod 𝒎
where: 𝒙= is the integer value of letters in the alphabet 𝒂,𝒃= the key for the cipher (***Key 𝙗 is basically the magnitude of the shift) mod 𝒎 (modulus 𝒎)= is the length of the alphabet
This means that we must multiply our integer value for the plaintext letter by 𝒂, and then add 𝒃 to the result. Finally, take the mod 𝒎 (it is the length of the alphabet minus 1 [our range 0 to m−1])
Example: Let's encrypt the word "SWORDCANE". Keys: 𝒂=7, 𝒃=4
1. Find the integer value of each letters in the plaintext alphabet (A=0, B=1, C=2 and so on.) 2. With the integer value of the plaintext letters, perform the calculations of the values. ¬ 𝐄(𝒙)=(𝒂𝒙+𝒃) mod 𝒎 3. Ensure all the answers were calculated by the modulus and convert the integers back to ciphertext letters. ¬ 𝐄(𝒙)=(7𝒙+4) mod 26
Therefore, the encryption of the word "SWORDCANE" to Affine cipher is "ACYTZSERG"
[DECRYPTION] In deciphering Affine cipher, we must perform the inverse functions on the cipher text to retrieve the plaintext. Once again, we must convert each cipher text letters to integer values. The decrytion process is given by this formula: 𝑫(𝒙)=𝒄(𝒙-𝒃) mod 𝒎
where: 𝒙= is the integer value of letters in the alphabet 𝒄= modular multiplicative inverse of 𝒂 𝒂,𝒃= the key for the cipher (***Key 𝙗 is basically the magnitude of the shift)
***Note: to find the multiplicative inverse of 𝒂, think of a number that when you will multiply to 𝒂 mod 26, you can get an answer of 1.
Example: Let's decrypt the enciphered text from the word Swordcane: ACYTZSERG Let's have the same keys: 𝒂=7, 𝒃=4
1. Using the keys: 𝒂=7, 𝒃=4, the first step is to find the modular multiplicative inverse of 𝒂. ¬ 𝑫(𝒙)= 𝒄 mod 𝒎(𝒙−𝒃) mod 𝒎 ¬ 𝑫(𝒙)= (𝒂) (𝒛) mod 26 ¬ 𝑫(𝒙)= (7) (𝒛) mod 26=1 ¬ 𝑫(𝒙)= (7) (15) mod 26=1 ¬ 𝑫(𝒙)= 105 mod 26=1 ¬ Answer: 15
2. Perform the inverse calculations on the integer value of the ciphertext letters. ¬ 𝑫(𝒙)= 15mod 26(𝒙−4) mod 𝒎
3. Ensure all the answers were calculated by the modulus and convert the integers back to plaintext letters. ¬ 𝑫(𝒙)= 15mod 26(𝒙−4) mod 26