SQLite Forum

HEX - What is the reverse function?
Because no matter how much you play with **data** it is still **data**.

You would have to write a loadable function which converts "data" that consists of a bunch of hex digits in text format into a bag-o-bytes composed of the interpretation of those hex digits.  

SQLite3 does **NOT** contain a function called, for example, UNHEX(arg) which takes a text string consisting of a bunch of hexidecimal digits and returns a blob (bag-o-bytes) containing the conversion of the data from one format to the other.

There are many very inefficient ways to get around the fact that such a function does not exist.  For example, you can play with recursive CTE's to do the decoding, you can construct a constant from your *data* and have it dynamically executed, or any number of other work-arounds.

However **there is no builtin UNHEX function that reverses the operation performed by the HEX function**.  If you want one, then you can write one.