COSCUP-ap-demo/demo/utils/key.py
SouthFox 29cc7017cb
Some checks failed
ci/woodpecker/push/lint Pipeline was successful
ci/woodpecker/push/test Pipeline failed
[lint] disable W0511(fixme)
- unused-import
- wrong-import-order
2023-07-12 00:56:58 +08:00

10 lines
313 B
Python

#!/usr/bin/env python3
"""process Key."""
from pathlib import Path
from Crypto.PublicKey import RSA
def get_pubkey_as_pem(key_path: Path) -> str:
"""Exporting public key from private key file."""
text = key_path.read_text()
return RSA.import_key(text).public_key().export_key("PEM").decode("utf-8")