def convert_to_hash(input_string, max_length):
 if (not isinstance(input_string, basestring)):
  raise Exception(('Expected string, received %s of type %s' % (input_string, type(input_string))))
 encoded_string = base64.urlsafe_b64encode(hashlib.sha1(input_string.encode('utf-8')).digest())
 return encoded_string[:max_length]

def convert_to_hash ( input_string , max_length ) : if ( not isinstance ( input_string , basestring ) ) : raise Exception ( ( 'Expected string, received %s of type %s' % ( input_string , type ( input_string ) ) ) ) encoded_string = base64 . urlsafe_b64encode ( hashlib . sha1 ( input_string . encode ( 'utf-8' ) ) . digest ( ) ) return encoded_string [ : max_length ]
convert a string to a sha1 hash .