Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Decrypt Matrix key export file
#!/usr/bin/env python3
import asyncio
import getpass
import json
import os
import sys
import nio
KEY_FILE = "element-keys.txt"
async def main() -> None:
if not os.path.exists(KEY_FILE):
sys.exit("Did not find file " + KEY_FILE)
passphrase = getpass.getpass("Enter passphrase: ")
plaintext = nio.crypto.key_export.decrypt_and_read(KEY_FILE, passphrase)
obj = json.loads(plaintext)
print(json.dumps(obj, indent=4))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment