Created
July 21, 2020 00:50
-
-
Save nemesifier/8678f54397ea40f9ab63f952e6947db3 to your computer and use it in GitHub Desktop.
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 codecs | |
from cryptography.hazmat.primitives.asymmetric.x25519 import X25519PrivateKey | |
from cryptography.hazmat.primitives import serialization | |
# generate private key | |
private_key = X25519PrivateKey.generate() | |
bytes_ = private_key.private_bytes( | |
encoding=serialization.Encoding.Raw, | |
format=serialization.PrivateFormat.Raw, | |
encryption_algorithm=serialization.NoEncryption() | |
) | |
print(codecs.encode(bytes_, 'base64').decode('utf8').strip()) | |
# derive public key | |
pubkey = private_key.public_key().public_bytes(encoding=serialization.Encoding.Raw, format=serialization.PublicFormat.Raw) | |
print(codecs.encode(pubkey, 'base64').decode('utf8').strip()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment