tonibofarull
tonibofarull

Reputation: 75

Reduce time on a RSA decryption in Python

I have written a RSA code in Python, but when it makes the decryption it take a lot of time (hours and hours). That's because it calculate the private key (that is very long) and then it decrypt the cryptogram raising it to the private key and making the module.

How i can reduce this time?

Code:

d = (e**(m-1))
M2 = (C**d)%n

M2 is the real message, d is the private key

Upvotes: 2

Views: 386

Answers (1)

Dan D.
Dan D.

Reputation: 74675

Use pow(C,d,n) rather than (C**d)%n as pow properly does modular exponentiation.

Upvotes: 5

Related Questions