def hex2num(s):
	"""Convert a string of hexadecimal digits to an integer."""

	n = 0

	for i in range(0,len(s)):

		a = ord(s[len(s)-i-1])
		if (a >= 48) & (a <= 57):
			n = n | ((a-48) << (i*4))
		elif (a >= 65) & (a <= 70):
			n = n | ((a-65+10) << (i*4))
		elif (a >= 97) & (a <= 102):
			n = n | ((a-97+10) << (i*4))
		else:
			return None

	return n