I've been looking at an online Public Key Encryption Example (summarized below). It seems to me that choosing cyphertext = plaintext^(key) mod n
would produce the same ciphertext letter for a particular plaintext letter, leading to easy frequency analysis of the output. Would there be a way to modify the example so that this isn't the case? Is there something I'm missing in the results? Thanks!
Summary of method:
- Pick a pair of large prime numbers at random (e.g., 3, 11 (not large in this case))
- Compute product:
n = p × q = 3 × 11 = 33
- Compute the value of Euler's totient function of n:
φ(n): φ(n) = (p-1) × (q-1) = 2 × 10 = 20
- Pick any number less than and relatively prime to φ(n) (e.g., 7)
- Compute the matching private or decryption key d, as the inverse of e modulus φ(n).
d = inv of e mod φ(n) = inv(7) mod 20 = 3
- Encrypt:
cyphertext = plaintext^(key) mod n