def encode_impl
import qasim-bend-kit@0.1.0.2/libs/AES256GCM.bend as AES256GCMimport Base
243def encode_impl(envelope: Envelope) -> String:
244 match envelope:
245 case Envelope{nonce, ciphertext, tag, valid}:
246 match nonce:
247 case Nonce{nonce_bytes, size, valid}:
248 "v1." ++ hex_bytes(fixed_bytes(12n, nonce_bytes)) ++ "." ++
249 hex_bytes(fixed_bytes(16n, tag_bytes(tag))) ++ "." ++
250 hex_bytes(ciphertext)