21 lines
597 B
Python
21 lines
597 B
Python
from cryptography.fernet import Fernet
|
|
from random_art.randomart import drunkenwalk, draw
|
|
from random import choices
|
|
from string import ascii_letters, digits
|
|
import os
|
|
from .abc import Key
|
|
|
|
|
|
def generate_keys():
|
|
key = Fernet.generate_key()
|
|
path = os.path.join(".sing", "system", ".keyfile")
|
|
hash = "".join(choices(ascii_letters + digits, k=10))
|
|
randomart = draw(drunkenwalk(key), hash)
|
|
print(f"The Key is {key}")
|
|
print("The Key's randomart is")
|
|
print(randomart)
|
|
key = Key(path, key, hash, randomart)
|
|
key.dump()
|
|
print(f"Saved Keys in {path}")
|
|
return key
|