Files
crypto/ChaCha20_Poly1305_64/doc/sanity.py
2026-07-26 17:35:24 -07:00

16 lines
457 B
Python

import base64
from chacha20poly1305 import ChaCha20Poly1305
cleartext=base64.decodebytes(b"RQAAVOVGQABAAUFMCgoAAgoKAAEIAPlcbAAAAG+tIvUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA")
key = base64.decodebytes(b"IA7buFUDsARj+YequW4OfQR3JsaE9M88dpXKrDjKzIs=")
nonce = bytes([0]*12)
cip = ChaCha20Poly1305(key)
ciphertag = cip.encrypt(nonce, cleartext)
ciphertext = ciphertag[:-16]
tag = ciphertag[-16:]
print(ciphertext)
print(tag)