auth.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:xmpp-cloud-auth 作者: jsxc 项目源码 文件源码
def auth_update_cache(self):
        if '' in self.ctx.cache_db: # Cache disabled?
            return
        key = self.username + ':' + self.domain
        now = self.now # For tests
        snow = str(now)
        try:
            salt = bcrypt.gensalt(rounds=self.ctx.bcrypt_rounds)
        except TypeError:
            # Old versions of bcrypt() apparently do not support the rounds option
            salt = bcrypt.gensalt()
        pwhash = bcrypt.hashpw(self.password, salt)
        if key in self.ctx.cache_db:
            (ignored, ts1, tsv, tsa, rest) = self.ctx.cache_db[key].split("\t", 4)
            self.ctx.cache_db[key] = "\t".join((pwhash, ts1, snow, snow, rest))
        else:
            self.ctx.cache_db[key] = "\t".join((pwhash, snow, snow, snow, ''))
        self.try_db_sync()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号