Closes #1191.
The script is passed as a hex string, but no one should care. The hash is a hex-encoded LE value, but no one should care either. Hex might change to base64, LE to BE, no one outside these functions should care about that.
part of #904