chatgpt/encryption-on-apis/gen-private-key.py
2022-12-17 22:39:21 +02:00

21 lines
470 B
Python
Executable File

#!/usr/bin/python3
from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives.asymmetric import ec
from cryptography.hazmat.primitives import serialization
def gen_key():
private_key = ec.generate_private_key(
ec.SECP256K1(), default_backend()
)
return private_key
if __name__ == '__main__':
key = gen_key()
hexkey = key.private_numbers().private_value.to_bytes(32, 'big').hex()
print(hexkey)