While implementing RSA encryption/decryption (using python), the plaintext doesn't match with the decrypted ciphertext for large values of plaintext. Works fine for smaller values for plaintext (numeric value).
Input: p=53 q=59 e=3 plaintext = 1000 (private key computed as 2011)
Here, the decryption gives
1000 as the plaintext, which is correct.
Input: p=53 q=59 e=3 plaintext = 10000 (private key computed as 2011)
Here, after the decryption, the computed plaintext is
619 (which should be
The code for the same is here,
def encrypt(plaintext): ciphertext = (plaintext**publicKey) % (self.n) return ciphertext def decrypt(ciphertext): plaintext = (ciphertext**privateKey) % (self.n) return plaintext
Considering the algorithm will be used to encrypt/decrypt alphanumeric text, which will produce large numeric values, what modifications are needed or am I missing something?
ps: Checking for multiple values of plaintext,it may be happening because
n=3127 and any plaintext greater than
3127 will not produce the original plaintext upon decryption. I might be wrong.
How to make it work for plaintext greater than