Created
July 14, 2013 01:49
-
-
Save rikaardhosein/5992884 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from Crypto.PublicKey import pubkey | |
from Crypto.Util import number | |
from Crypto.PublicKey import RSA | |
from Crypto.PublicKey import _slowmath | |
import fractions | |
import sys | |
import os | |
e = long(65537) | |
p = long(13097286606179453667665592444299109782484218865253457545521978739889248320232481682880143106432871469494586765663594908396375009598486558938138835723794021) | |
q = long(10196183246368760603869192593971202143897281417220455881063414616103901438182656326076501376638806928762094749150020638960102206987607293047096627515275223) | |
n = long(p*q) | |
d = long(pubkey.inverse(e, (p-1)*(q-1))) | |
key = _slowmath._RSAKey() | |
key.e = e | |
key.p = p | |
key.q = q | |
key.n = n | |
key.d = d | |
keypair = RSA._RSAobj(RSA.RSAImplementation(),key) | |
with open("pub", "w") as pubfile, open("id_rsa", "w") as privfile: | |
privfile.write(keypair.exportKey()) | |
pubfile.write(keypair.publickey().exportKey()) | |
os.system("ssh-keygen -m PKCS8 -i -f pub > id_rsa.pub && rm pub") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment