本文整理汇总了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)
示例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
示例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})