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