Good catch about catching if the key isn't valid hex.

I use the Crypto Base64 parser because it returns a "WordArray" or some such data structure which is an array of ints, not an ArrayBuffer/string, and is used directly by the SHA256 method.  Same for the reverse, converts from a WordArray to hex.  Otherwise, I'de need to convert to/from that form myself.