crypto.py 文件源码

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

项目:farfetchd 作者: isislovecruft 项目源码 文件源码
def getHMACFunc(key, hex=True):
    """Return a function that computes the HMAC of its input using the **key**.

    :param bool hex: If True, the output of the function will be hex-encoded.
    :rtype: callable
    :returns: A function which can be uses to generate HMACs.
    """
    h = hmac.new(key, digestmod=DIGESTMOD)
    def hmac_fn(value):
        h_tmp = h.copy()
        h_tmp.update(value)
        if hex:
            return h_tmp.hexdigest()
        else:
            return h_tmp.digest()
    return hmac_fn
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号