Skip to content

Instantly share code, notes, and snippets.

@jboynyc
Created November 22, 2024 23:53
Show Gist options
  • Save jboynyc/16b96b3c1d179a9cc7add244c1725876 to your computer and use it in GitHub Desktop.
Save jboynyc/16b96b3c1d179a9cc7add244c1725876 to your computer and use it in GitHub Desktop.
RSA keypair in Python
#!/usr/bin/env nix-shell
#! nix-shell -i python3 -p "python3.withPackages (p: [ p.rsa ])"
from os import cpu_count
import rsa
(pub, priv) = rsa.newkeys(2048, poolsize=cpu_count())
# public key in PEM format
print(pub.save_pkcs1().decode())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment