payment.py 文件源码

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

项目:pyTeliumManager 作者: Ousret 项目源码 文件源码
def lrc(data):
        """
        Calc. LRC from data. Checksum
        :param bytes|str data: Data from which LRC checksum should be computed
        :return: 0x00 < Result < 0xFF
        :rtype: int
        """
        if isinstance(data, str):
            data = data.encode(TERMINAL_DATA_ENCODING)
        elif not isinstance(data, bytes):
            raise TypeError("Cannot compute LRC of type {0}. Expect string or bytes.".format(str(type(data))))
        return reduce(xor, [c for c in data]) if six.PY3 else reduce(xor, [ord(c) for c in data])
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号