DeaD_EyE

tor private public with nacl

Jan 29th, 2022
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.49 KB | None | 0 0
  1. """
  2. Install nacl:
  3.  
  4. pip install pynacl
  5. """
  6.  
  7. from base64 import b32encode
  8. from typing import NamedTuple
  9.  
  10. from nacl.public import PrivateKey
  11.  
  12.  
  13. class ClientAuth(NamedTuple):
  14.     private: str
  15.     public: str
  16.  
  17.  
  18. def gen_keys() -> ClientAuth:
  19.     private = PrivateKey.generate()
  20.     private_key = b32encode(bytes(private)).decode("ascii")[:-4]
  21.     public_key = b32encode(bytes(private.public_key)).decode("ascii")[:-4]
  22.     return ClientAuth(private_key, public_key)
  23.  
  24.  
  25. print(gen_keys())
  26.  
Add Comment
Please, Sign In to add comment