Skip to content

Instantly share code, notes, and snippets.

@aaronraimist
Created June 23, 2021 00:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aaronraimist/d36a73a284463444dfd7e0b08271db92 to your computer and use it in GitHub Desktop.
Save aaronraimist/d36a73a284463444dfd7e0b08271db92 to your computer and use it in GitHub Desktop.
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))
asyncio.get_event_loop().run_until_complete(main())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment