Skip to content

Instantly share code, notes, and snippets.

@PyMaster22
Created November 13, 2020 19:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PyMaster22/a5da50057ddcf0b1e5764004e72793f8 to your computer and use it in GitHub Desktop.
Save PyMaster22/a5da50057ddcf0b1e5764004e72793f8 to your computer and use it in GitHub Desktop.
Generates RSA keys
import os, math
key_name = input("Private key name: ")
try: security = int(input("Secity level:\n[1] 1024\n[2] 2048\n[3] 4096\n[4] Custom\n\n[3]"))
except ValueError: security = 3
if(security == 4): security = math.log2(int(input("Bits: "))) - 9
cmd = "openssl genpkey -algorithm RSA -out ./"+key_name+" -pkeyopt rsa_keygen_bits:"+str(2 ** (int(security) + 9))+";openssl rsa -in ./"+key_name+" -pubout -out ./"+key_name+".pub"
os.system(cmd)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment