Created
January 16, 2023 18:03
-
-
Save wiktorpyk/56609de148d6a2983495e742aa038cb2 to your computer and use it in GitHub Desktop.
python-rsa example usage
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
import rsa | |
public, private = rsa.newkeys(512) | |
# private = rsa.PrivateKey.load_pkcs1(open('private.pem', mode='rb').read()) | |
print(f"Public key: {public}") | |
print(f"Private key: {private}") | |
message = b"Hello world!" | |
encrypted_message = rsa.encrypt(message, public) | |
print(f"Encrypted message: {encrypted_message.hex()}") | |
message = rsa.decrypt(encrypted_message, private) | |
print(f"Decrypted message: {message}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment