def _hash_internal(method, salt, password):
 if (method == 'plain'):
  return password
 if salt:
  if (method not in _hash_mods):
   return None
  if isinstance(salt, unicode):
   salt = salt.encode('utf-8')
  h = hmac.new(salt, None, _hash_mods[method])
 else:
  if (method not in _hash_funcs):
   return None
  h = _hash_funcs[method]()
 if isinstance(password, unicode):
  password = password.encode('utf-8')
 h.update(password)
 return h.hexdigest()

def _hash_internal ( method , salt , password ) : if ( method == 'plain' ) : return password if salt : if ( method not in _hash_mods ) : return None if isinstance ( salt , unicode ) : salt = salt . encode ( 'utf-8' ) h = hmac . new ( salt , None , _hash_mods [ method ] ) else : if ( method not in _hash_funcs ) : return None h = _hash_funcs [ method ] ( ) if isinstance ( password , unicode ) : password = password . encode ( 'utf-8' ) h . update ( password ) return h . hexdigest ( )
internal password hash helper .