Obviously you have two different data-types at play -- strings (like 'New') and byte-arrays (like the result of RANDOM_BYTES).

Try to cast everything to byte-arrays, don't HEX anything, concat byte-arrays, pass byte-arrays for keys and data.

Using strings (or hex strings like '882714215509c4084d68f27dce978d') will be the root of all possible flaws you can introduce in your code.

Edit: In MySQL/MariaDB there is so called hex literal like x'E764DF04463B55E9E2305934266227A1' or you can use a clutch like UNHEX('E764DF04463B55E9E2305934266227A1'). The latter is like using CLng("42") instead of just 42& in VBx.

cheers,
</wqw>