simple rsa from javascript to python

A

Astan Chee

Hi,
I've got a simple javascript that looks like this:

var public_key_mod =
"B99808B881F3D8A620F043D70B89674C0A120417FBD3690B3472589C641AD5D422502D0B26CADF97E2CB618DDDBD06CA0619EBBFB328A2FA31BD0F272FE3791810546E04BF42F05DB620FC7B4D0A2EAA17C18FF30C84D93341205C1D6EAD6ACBF2F08E334049DEBF31555CF164AD5CCE437B1AB5EFFEE1FF38552B63EDEF74861E665D90D5AB76D85F5242F42BA29F20EC64553D08020C1E37909341A25F339F802A83EE65E1559AC1CDFE0837160759770D27A058CED0C3771356BCAC8739A0FEF8F344CF64833CDDECC41BBE76BB2F1F8229EB04C72FABA91E4798A3DDFD9100A5171490B30F30EAADF6FDA7677F63CD77D1E6E88F79A6CED5A4966DD6459F";
var public_key_exp = "010001";
var my_text = "this is a text.,)";
var public_key = RSA.getPublicKey( public_key_mod, public_key_exp );
var encrypted_text = RSA.encrypt( my_text, public_key );

and I'm trying to convert this into python and I'm rather stuck with
pycrypto as there is no example on how to make the public key with a
mod and exponent (or I've probably missed it).
Thanks for any help!
 
N

Nobody

and I'm trying to convert this into python and I'm rather stuck with
pycrypto as there is no example on how to make the public key with a mod
and exponent (or I've probably missed it).

from Crypto.PublicKey import RSA
mod = long("B99808B881F3D8A...", 16) # truncated for clarity
exp = long("010001", 16)
rsa = RSA.construct((mod, exp))
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top