HEX string to unsigned long.

In which case the same loop without the shift.
You'll also need to cast the "char" to "unsigned char"

You'll also have at most ten bits of data in a 32 bit variable.