Use HexToBin:
HexToBin(PChar(hash), x, SizeOf(x));
Now, the docs say:
The hexadecimal number must use lower-case characters; HexToBin does not recognize upper-case characters.
But it turns out that this statement is incorrect and HexToBin
works no matter what case text you give it.