Last active
November 29, 2021 18:05
-
-
Save kavishkagihan/8f09757d76ad753e7bebbdf231d96c38 to your computer and use it in GitHub Desktop.
This file contains 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
from Crypto.PublicKey import RSA | |
from base64 import b64encode as b64 | |
def int2bytes(number): | |
return number.to_bytes((number.bit_length() + 7) // 8, byteorder="big") | |
fp = open("publickey.crt", "r") | |
key = RSA.importKey(fp.read()) | |
fp.close() | |
n = b64(int2bytes(key.n)).decode() | |
e = b64(int2bytes(key.e)).decode() | |
print("n:", n.replace('+', '-').replace('/', '_')) | |
print("e:", e) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment