Implement encodeHex.
New encodeHex and decodeHex with test cases.