def set_password(self, raw_password): if raw_password is None: self.set_unusable_password() else: algo = 'sha1' hsh = get_hexdigest(algo, '', raw_password) self.password = '******' % hsh
def check_password(self, raw_password): """ Returns a boolean of whether the raw_password was correct. Handles encryption formats behind the scenes. """ # Backwards-compatibility check. Older passwords won't include the # algorithm or salt. if '$' not in self.password: is_correct = (self.password == \ get_hexdigest('sha1', '', raw_password)) return is_correct return check_password(raw_password, self.password)