当前位置: 首页>>代码示例>>Python>>正文


Python Checksum.generate_checksum方法代码示例

本文整理汇总了Python中Checksum.generate_checksum方法的典型用法代码示例。如果您正苦于以下问题:Python Checksum.generate_checksum方法的具体用法?Python Checksum.generate_checksum怎么用?Python Checksum.generate_checksum使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Checksum的用法示例。


在下文中一共展示了Checksum.generate_checksum方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: update_packet

# 需要导入模块: import Checksum [as 别名]
# 或者: from Checksum import generate_checksum [as 别名]
    def update_packet(self, msg_type=None, seqno=None, data=None, full_packet=None, update_checksum=True):
        """
        This function handles safely changing the contents of a packet. By
        default, we re-compute the checksum every time the packet is updated.
        However, you can disable this if you intend to create a corrupted
        packet.

        Note that the checksum is calculated over the NON-0-indexed sequence number.
        """
        if not self.bogon:
            if msg_type == None:
                msg_type = self.msg_type
            if seqno == None:
                seqno = self.seqno
            if data == None:
                data = self.data

            if msg_type == "ack":  # doesn't have a data field, so handle separately
                body = "%s|%d|" % (msg_type, seqno)
                checksum_body = "%s|%d|" % (msg_type, seqno + self.start_seqno_base)
            else:
                body = "%s|%d|%s|" % (msg_type, seqno, data)
                checksum_body = "%s|%d|%s|" % (msg_type, seqno + self.start_seqno_base, data)
            if update_checksum:
                checksum = Checksum.generate_checksum(checksum_body)
            else:
                checksum = self.checksum
            self.msg_type = msg_type
            self.seqno = seqno
            self.data = data
            self.checksum = checksum
            if full_packet:
                self.full_packet = full_packet
            else:
                self.full_packet = "%s%s" % (body, checksum)
开发者ID:rshane,项目名称:EE122Proj1,代码行数:37,代码来源:orig_TestHarness.py

示例2: make_packet

# 需要导入模块: import Checksum [as 别名]
# 或者: from Checksum import generate_checksum [as 别名]
 def make_packet(self,msg_type,seqno,msg):
     # msg_type can be either 'start', 'end', 'data', or 'ack'
     # seqno is simply the sequence number of the packet
     # msg is simply the packet's data
     body = "%s|%d|%s|" % (msg_type,seqno,msg)
     checksum = Checksum.generate_checksum(body)
     packet = "%s%s" % (body,checksum)
     return packet
开发者ID:Ryan-Yu,项目名称:cs168-proj2,代码行数:10,代码来源:BasicSender.py

示例3: __sign__

# 需要导入模块: import Checksum [as 别名]
# 或者: from Checksum import generate_checksum [as 别名]
def __sign__(param_dict):
    param_dict['CHECKSUMHASH'] = Checksum.generate_checksum(param_dict=param_dict, merchant_key={YOUR_MERCHANT_KEY})
开发者ID:Poorvak,项目名称:ai_nlp_bot,代码行数:4,代码来源:chatty.py


注:本文中的Checksum.generate_checksum方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。