Check if the length of the string is appropriate and if it contains hexadecimal characters. Also document this function. Closes #12814.