Evren Esat Ozkan
sleytr at gmail.com
Thu Jul 17 14:48:50 CEST 2008
Thank you very much. Your code is worked like a charm and saved my
On Jul 4, 6:19 pm, marek.ro... at wp.pl wrote:
> Evren Esat Ozkan napisa³(a):
> > Hello,
> > I'm trying to encrypt a string with RSA. But it needs to be compitable
> > lots of different things about RSA and RSA in Python. But could not
> > My experiments could be seen at:http://dpaste.com/hold/60741/
> > Python libraries which I tried;
> > * PyCrtypo:http://www.amk.ca/python/code/crypto.html
> > * rsa library fromhttp://www.stuvel.eu/rsa
> > How could I create the same results with the JS library in Python.
> > Any help would be appreciated
> > Evren,
> namely processing it in reverse. Try encrypting ciphertext[::-1]
> instead of just ciphertext.
> public_modulus_hex = '9F2E..snip..4BC7'
> public_exponent_hex = '10001'
> public_modulus = int(public_modulus_hex, 16)
> public_exponent = int(public_exponent_hex, 16)
> def encrypt(plaintext_text):
> # Beware, plaintext must be short enough to fit in a single block!
> plaintext = int(plaintext_text.encode('hex'), 16)
> ciphertext = pow(plaintext, public_exponent, public_modulus)
> return '%X' % ciphertext # return hex representation
> print encrypt('12345')
> print encrypt('12345'[::-1]) # Will return the value compatible with
> JS output
More information about the Python-list