I've decided to learn about RSA encryption since learning about the vernal cipher in a comp sci lecture. I grasp the idea behind RSA (it's very clever), however while trying to write my own C program to encrypt and decrypt a string of characters I have run into a few problems.
I am encrypting each character's ASCII value using the public key then decrypting the cipher text. However, I have found that sometimes the public key I have created will encrypt an ASCII value to 0, then there is no way to decrypt it as 0^anything = 0. I surely must be wrong here as binary can be encrypted/decrypted using RSA.
E.g.
- p = 3
- q = 5
- N = 15 (p*q)
- m = (p-1)(q-1) = 8
- e = 7 (coprime to m)
- d = 7 (7d(mod8) = 1 ... Before people have a go, I am only using 7 because it's convenient for this example (not for a secure encryption)
Now take the char "T" (ASCII value 84)
Run the encryption, the cipher text is = 0
0^7 (mod 8) = 0 ... not 84!
Can someone point me in the right direction please.
Thanks in advance