Created
November 22, 2024 23:53
-
-
Save jboynyc/16b96b3c1d179a9cc7add244c1725876 to your computer and use it in GitHub Desktop.
RSA keypair in Python
This file contains hidden or 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 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