import hmac


def hmacFunction(hashConstructor):
	"""
	Accepts the constructor of a hash algorithm and returns an HMAC function.

	:param hashConstructor: hashing algorithm (e.g. hashlib.md5)
	:return: hmac(str, key)
	"""
	def h(message, key):
		return hmac.new(key=key.encode('utf8', 'ignore'), msg=message.encode('utf8', 'ignore'), digestmod=hashConstructor).hexdigest()
	return h