原创 计算检验和:将消息头+会话头+事务头+操作消息按32位异或(Python版)
2007-10-30 09:57
453 查看
版权所有,转载请注明出处与作者
# -*- coding: iso-8859-1 -*-
#!/usr/bin/python
# Author:JiangXiaoQiang
# E-mail:athlong@hotmail.com
# Webpage:www.awrhyme.cn
import binascii
q=[]
def crc64(msg):
s0=00
s2=00
s3=00
s1=00
i=0
j=0
restr=''
l=len(msg)
while i<l:
s0^=ord(msg[i])
s1^=ord(msg[i+1])
s2^=ord(msg[i+2])
s3^=ord(msg[i+3])
i+=4
q.append(~s0)
q.append(~s1)
q.append(~s2)
q.append(~s3)
while j<4:
restr+=contr(q[j])
j+=1
return restr.replace('0x','').upper()
def contr(q):
high = (q& 0xf0) >> 4
low = (q& 0xf)
print 'high',high,'low',low
return(str(hex(high))+str(hex(low)))
# -*- coding: iso-8859-1 -*-
#!/usr/bin/python
# Author:JiangXiaoQiang
# E-mail:athlong@hotmail.com
# Webpage:www.awrhyme.cn
import binascii
q=[]
def crc64(msg):
s0=00
s2=00
s3=00
s1=00
i=0
j=0
restr=''
l=len(msg)
while i<l:
s0^=ord(msg[i])
s1^=ord(msg[i+1])
s2^=ord(msg[i+2])
s3^=ord(msg[i+3])
i+=4
q.append(~s0)
q.append(~s1)
q.append(~s2)
q.append(~s3)
while j<4:
restr+=contr(q[j])
j+=1
return restr.replace('0x','').upper()
def contr(q):
high = (q& 0xf0) >> 4
low = (q& 0xf)
print 'high',high,'low',low
return(str(hex(high))+str(hex(low)))
相关文章推荐
- 利用Python操作消息队列RabbitMQ的方法教程
- 事务操作的统计,TPS的计算,隔离级别的读提交
- django-mysql 中的金钱计算事务处理 分类: 小技巧 python学习 mysql 2015-07-27 16:52 10人阅读 评论(0) 收藏
- python科学计算六:scipy矩阵操作
- Python操作rabbitmq系列(四):根据类型订阅消息
- 关于mysql-python的简单事务操作
- (原创)Python文件与文件系统系列(2)——os模块对文件、文件系统操作的支持
- python实现redis三种cas事务操作
- [python计算金额]decimal常用操作
- (原创)数据结构---队栈操作(Python)
- Python操作RabbitMQ服务器实现消息队列的路由功能
- TSsringList使用 WM_MouseMove消息 移位异或操作(y shl 16 or X)
- [原创]Python小工具 —— 计算 文件 或 文件夹及其所有子文件夹中所有文件 的 代码行数
- python 操作消息队列
- Python3.x的mysqlclient的安装、Python操作mysql,python连接MySQL数据库,python创建数据库表,带有事务的操作,CRUD
- Python学习笔记 --- 操作时间,计算时间差
- Python操作RabbitMQ服务器实现消息队列的路由功能
- Python实现完整的事务操作示例
- Python处理菜单消息操作示例【基于win32ui模块】
- 【转】python win32api win32gui win32con 简单操作教程(窗口句柄 发送消息 常用方法 键盘输入)