encoder.py 文件源码

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

项目:segno 作者: heuer 项目源码 文件源码
def calc_structured_append_parity(content):
    """\
    Calculates the parity data for the Structured Append mode.

    :param str content: The content.
    :rtype: int
    """
    if not isinstance(content, str_type):
        content = str(content)
    try:
        data = content.encode('iso-8859-1')
    except UnicodeError:
        try:
            data = content.encode('shift-jis')
        except (LookupError, UnicodeError):
            data = content.encode('utf-8')
    if _PY2:
        data = (ord(c) for c in data)
    return reduce(xor, data)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号