Here, we are first receiving the key components of the encryption key, i.e. a and b from the user. We are verifying whether gcd(a, symbol size) = 1 and b < symbol size. After that, we are generating the encryption key as:
key = a * symbol size + b
Now, we are receiving the plaintext from the user. And, each letter from the plaintext is encrypted using the affine cipher. Please note that each letter of the alphabet is converted into an integer using the following operation:
ord(c) – ord(‘a’) where c is a letter in the alphabet
Similarly, after the encryption operation, we obtain an integer. The integer is then converted into a letter in the alphabet using the following operation:
chr(n + (ord(‘a’)) where n is an integer less than the symbol size
The decryption operation is performed as explained earlier. We are first calculating the key components of the decryption key and then we are using the key components to decrypt each letter of the ciphertext.
I hope this helps. However, readers who want to know more about how different cryptographic algorithms work and how they are used in various secure network protocols can refer to the book “Cryptography And Public Key Infrastructure.”






0 Comments