Skip to content

Instantly share code, notes, and snippets.

@carlok
carlok / 0_export_public_key.py
Last active May 13, 2023 21:51 — forked from aellerton/0_export_public_key.py
Python sign message with private key and verify with public key
#!/usr/bin/env python
"""Extract the public key from the private key and write to a file.
"""
from Crypto.Hash import SHA256
from Crypto.Signature import PKCS1_v1_5
from Crypto.PublicKey import RSA
with open("private_key.pem", "r") as src:
private_key = RSA.importKey(src.read())