csrf.py 文件源码

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

项目:liberator 作者: libscie 项目源码 文件源码
def _salt_cipher_secret(secret):
    """
    Given a secret (assumed to be a string of CSRF_ALLOWED_CHARS), generate a
    token by adding a salt and using it to encrypt the secret.
    """
    salt = _get_new_csrf_string()
    chars = CSRF_ALLOWED_CHARS
    pairs = zip((chars.index(x) for x in secret), (chars.index(x) for x in salt))
    cipher = ''.join(chars[(x + y) % len(chars)] for x, y in pairs)
    return salt + cipher
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号