Skip to content Skip to sidebar Skip to footer

How To Specify Rsa Padding In Python Pycrypto

I got a pice of java RSA decrypt code, now I want to express in Python pycrypto. but I got different ciphertext although using same private key, and server only access ciphertext t

Solution 1:

I absolutely don't get what you're trying to do in the Java code, but it is not going right.

PKCS#1 v1.5 padding for encryption uses at least 8 bytes set to a random value in the range 1..255. This means that the outcome after modular exponentiation is completely random within the range 0 to N (the modulus). So each time you encrypt, using either Java or Python, the result should be completely random. This is required for the cipher to be IND_CPA secure; you would distinguish between two identical plaintext otherwise.

There is one good way to test encryption: decrypt it and see if you get the same binary plaintext. You should be able to test this cross-platform.

Post a Comment for "How To Specify Rsa Padding In Python Pycrypto"