Build an encryption and decryption protocol to secure messages sent between a client and a robotic controller for Medra.
Implement secure_message(mode, data, key, nonce=None). Encryption must return nonce_hex:ciphertext_hex:tag_hex; decryption must validate the tag and return the original UTF-8 message or None for invalid input or tampering. The supplied compatibility vectors are normative, and the implementation must support arbitrary UTF-8 strings, keys, and nonces.
def secure_message(mode, data, key, nonce=None):