Last active
November 14, 2022 13:20
-
-
Save iarp/f073f83912815c17235946c77db152b2 to your computer and use it in GitHub Desktop.
OwnTracks Python decrypt function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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