24 lines
372 B
Python
24 lines
372 B
Python
import base64
|
|
import os
|
|
|
|
# Generates a key in the format compatible with Synapse and Vona.
|
|
|
|
|
|
def mkchar() -> str:
|
|
return os.urandom(4).hex()[:1]
|
|
|
|
|
|
def random(length):
|
|
return (
|
|
base64.b64encode(os.urandom(length))
|
|
.decode("utf-8")[:length]
|
|
.replace("/", mkchar())
|
|
.replace("+", mkchar())
|
|
)
|
|
|
|
|
|
key = random(43)
|
|
key_id = random(6)
|
|
|
|
print(f"ed25519 {key_id} {key}")
|