-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrsa00.py
26 lines (18 loc) · 988 Bytes
/
rsa00.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import rsa
#(pubkey, privkey) = rsa.newkeys(1024)
#print pubkey
#n = 165138424261149263963666229661164814908887524950166142962960019363944425161240370251403452452001165143400173133423045791330687304650944332950460079059702342999940532642226896299225258939028313437520982527474148958262129523279095471616009516621824844891755906467794220597075349492626446841979774101805104112707
n = 0xEB2A38568661887FA180BDDB5CABD5F21C7BFD59C090CB2D245A87AC253062882729293E5506350508E7F9AA3BB77F4333231490F915F6D63C55FE2F08A49B353F444AD3993CACC02DB784ABBB8E42A9B1BBFFFB38BE18D78E87A0E41B9B8F73A928EE0CCEE1F6739884B9777E4FE9E88A1BBE495927AC4A799B3181D6442443
pubkey = rsa.PublicKey(n, 0x10001)
pub = pubkey.save_pkcs1()
pubfile = open('public.pem','w+')
pubfile.write(pub)
pubfile.close()
message = 'hello'
with open('public.pem') as publickfile:
p = publickfile.read()
print p
pubkey = rsa.PublicKey.load_pkcs1(p)
crypto = rsa.encrypt(message, pubkey)
print crypto
print type(crypto)