def make_user(self, **data): password = '******' in data and data['password'] or None del data['password'] assert password, 'The password must be provided.' u = User(**data) u.salt = self.generate_hash(Enigma.instance().random_number(), time()) u.secret = self.generate_hash(u.email, u.salt) u.hash = self.generate_hash(password, u.salt) return u
def generate(password, salt): return Enigma.instance().hash(password, salt)
def generate_hash(self, primary_factor, secondary_factor): return Enigma.instance().hash('%s %s' % (primary_factor, secondary_factor))
def generate(self): key = '%s/%s' % (AppSettings['cookie_secret'], time())\ if 'cookie_secret' in AppSettings\ else str(time()) return Enigma.instance().hash(key)
def set_password(self, password): self.hash = Enigma.instance().hash('%s %s' % (password, self.salt))