def check_password(self, raw_password): algo, salt, hsh = self['password'].split('$') return hsh == get_hexdigest(algo, salt, raw_password)
def set_password(self, raw_password): algo = project.setting('auth', 'password_algorithm_type', 'sha1') salt = get_hexdigest(algo, str(random.random()), str(random.random()))[:5] hsh = get_hexdigest(algo, salt, raw_password) self['password'] = u'%s$%s$%s' % (algo, salt, hsh)