Skip to content

Instantly share code, notes, and snippets.

@iarp
Last active November 14, 2022 13:20
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 iarp/f073f83912815c17235946c77db152b2 to your computer and use it in GitHub Desktop.
Save iarp/f073f83912815c17235946c77db152b2 to your computer and use it in GitHub Desktop.
OwnTracks Python decrypt function
import base64
from libnacl import crypto_secretbox_KEYBYTES as KEYLEN
from libnacl.secret import SecretBox
def decrypt_payload(payload):
key = 'abcedf'.encode('utf-8')
key = key.ljust(KEYLEN, b'\0')
ciphertext = base64.b64decode(payload)
return SecretBox(key).decrypt(ciphertext).decode('utf-8')
posted_data = json.loads(request.body.decode('utf-8'))
posted_data = decrypt_payload(posted_data['data'])
posted_data = json.loads(posted_data)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment