def hash(string, hashtype):
   """
    This function returns a defined hash for a string 
    
    :param string: a string to hash
    :type filename: string
    :param hashtype: The hashing function which should be used. It has to be defined in hashlib
    :type hashtype: String
    :return type: String representation of a hex number
   """
   # hash binary representation of string and convert it to hex
   return eval('hashlib.{}(string.encode())'.format(hashtype)).hexdigest()