Install 2.6 python-crypto

opkg update
opkg remove python-crypto
wget http://www.ibuyopenwrt.com/images/software/python-crypto_2.6-1_ar71xx.ipk
opkg install python-crypto_2.6-1_ar71xx.ipk
Installing python-crypto (2.6-1) to root...
Configuring python-crypto.
nano rsa.py
from Crypto.PublicKey import RSA
from Crypto.Util.randpool import RandomPool
def encrypt_RSA(message,public_key):
    encrypted = public_key.encrypt(message,64)
    return encrypted[0]
def decrypt_RSA(package,private_key):
    decrypted = private_key.decrypt(package)
    return decrypted
pool = RandomPool()
pool.stir()
rsa_key = RSA.generate(1024,pool.get_bytes)
print rsa_key.publickey().exportKey("PEM")
print rsa_key.exportKey("PEM")
test = encrypt_RSA("Hello World!",rsa_key.publickey())
print test
print decrypt_RSA(test,rsa_key)
python rsa.py
-----BEGIN PUBLIC KEY-----
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDVlXuJ3LaJ4E6v5Iis+ULjddX7
BeYW2XKgXlUbzma6Sx4jbyGOim1bCKc+IauXl8RvcPCKS7DVmhL7b9v82YX6XMC8
/Mx0SQ5UHkIbhYyWNU/+Tddu2BBaRZIStzKO7O6LT1GpjgqO9fFmhvp6nNSRakZr
S5a5TP+7zhksHmeXawIDAQAB
-----END PUBLIC KEY-----
-----BEGIN RSA PRIVATE KEY-----
MIICXgIBAAKBgQDVlXuJ3LaJ4E6v5Iis+ULjddX7BeYW2XKgXlUbzma6Sx4jbyGO
im1bCKc+IauXl8RvcPCKS7DVmhL7b9v82YX6XMC8/Mx0SQ5UHkIbhYyWNU/+Tddu
2BBaRZIStzKO7O6LT1GpjgqO9fFmhvp6nNSRakZrS5a5TP+7zhksHmeXawIDAQAB
AoGABU/oeK9Sou8/RcSrWZIBheLCZbHp3RufbDmsaDqj93Iy17LF5OOwgJkgf70a
pXSS4Cqw8N+dEFL6seJAWHOYj2vkz6hu+ccvw8Q2O/Wi7D71LqNhUk3/jBPE1rvZ
UWSbvZ++MjAxlYk6saaD+vnJjAzu5jiTL+tNbS9GE62Yj1ECQQDdJKR/d1HmSAeY
vdClpdPsJ/sFP3UY+t3mUACNKaLcXeOA1DNQsAZn/fx0ePpiCw9uvsQxxHY/vOfl
WElJ1Uj/AkEA9z/RTh3RUeJrTtyH1RVECDmqnblSHkhcIErJfyaRTGHRCUHKrJWg
7Wd/Pek8u32Eu+4vgeKEn71BHBHG7QjllQJBAJCwC8y2ReiUUhwWfTAUKm8FzZAm
b7fzU0IAMAwsJLln2JUOwbBWKyrZG9cc3D1PnT5JJFangvK650LAG9tp6AMCQQDR
g9uqdWv+Fn7WOdxEvZuD2NHyi6rBjJG8r4Ml4xm2/yCy1nSXYMgYxN43KWDUhB2p
XsIVL00xS59T2OCX1jUtAkEAk/ogaS9dO2ap+llHcmsQ5sD/lcoaVMFCNBrcN9EC
2ZXR8QCT1geuELuOzREuGW/SmBzuj0IHBpSuHmNQ2l6KXQ==
-----END RSA PRIVATE KEY-----
▒▒▒w▒Т▒~l▒;.▒▒▒▒Q▒▒\xѳy`;N▒▒%▒▒E▒f֙▒▒|▒▒1
▒▒٣@▒▒▒ l▒΢hk1nW▒▒~▒▒d▒
Hello World!

 

 

 

Comments powered by CComment