Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #22557 > unrolled thread

simple rsa from javascript to python

Started byAstan Chee <astan.chee@gmail.com>
First post2012-04-02 16:19 -0700
Last post2012-04-03 06:12 +0100
Articles 2 — 2 participants

Back to article view | Back to comp.lang.python


Contents

  simple rsa from javascript to python Astan Chee <astan.chee@gmail.com> - 2012-04-02 16:19 -0700
    Re: simple rsa from javascript to python Nobody <nobody@nowhere.com> - 2012-04-03 06:12 +0100

#22557 — simple rsa from javascript to python

FromAstan Chee <astan.chee@gmail.com>
Date2012-04-02 16:19 -0700
Subjectsimple rsa from javascript to python
Message-ID<2aaac386-2223-4f70-aee5-a584dba5199a@r2g2000pbs.googlegroups.com>
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!

[toc] | [next] | [standalone]


#22570

FromNobody <nobody@nowhere.com>
Date2012-04-03 06:12 +0100
Message-ID<pan.2012.04.03.05.13.10.252000@nowhere.com>
In reply to#22557
On Mon, 02 Apr 2012 16:19:05 -0700, Astan Chee wrote:

> 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))

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web