Created
July 14, 2013 01:45
-
-
Save rikaardhosein/5992876 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
#!/usr/bin/env python | |
from time import time | |
from os import system | |
from Crypto.PublicKey import RSA | |
SEED = int(time()) | |
def randfunc(n): | |
def rand(): | |
global SEED | |
ret = SEED*0x1333370023004200babe004141414100e9a1192355de965ab8cc1239cf015a4e35 + 1 | |
SEED = ret | |
return (ret >> 0x10) & 0x7fff | |
ret = "" | |
while len(ret) < n: | |
ret += chr(rand() & 0xff) | |
return ret | |
keypair = RSA.generate(1024, randfunc) | |
with open("pub", "w") as pubfile, open("id_rsa", "w") as privfile: | |
privfile.write(keypair.exportKey()) | |
pubfile.write(keypair.publickey().exportKey()) | |
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