tbfh.py 文件源码

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

项目:tockloader 作者: helena-project 项目源码 文件源码
def _checksum (self, buffer):
        '''
        Calculate the TBF header checksum.
        '''
        # Add 0s to the end to make sure that we are multiple of 4.
        padding = len(buffer) % 4
        if padding != 0:
            padding = 4 - padding
            buffer += bytes([0]*padding)

        # Loop throw
        checksum = 0
        for i in range(0, len(buffer), 4):
            checksum ^= struct.unpack('<I', buffer[i:i+4])[0]

        return checksum
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号