context_processors.py 文件源码

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

项目:ctx 作者: decrypto-org 项目源码 文件源码
def ctx_processor():
    ctx_object = CTX()

    def ctx_protect(secret, origin=None, alphabet=None):
        protected_secret = ctx_object.protect(secret, origin, alphabet)
        return Markup(
            "<div data-ctx-origin='{origin_id}'>{permuted}</div>".format(
                origin_id=protected_secret['origin_id'],
                permuted=quote(protected_secret['permuted'])
            )
        )

    def ctx_permutations():
        return Markup(
            "<script type='application/json' id='ctx-permutations'>{permutations}</script>".format(
                permutations=dumps(
                    ctx_object.get_permutations()
                )
            )
        )

    return {
        'ctx_protect': ctx_protect,
        'ctx_permutations': ctx_permutations
    }
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号