- A+
201 ←A11=02
201 ←A11=02
8437102700C81D0000AEAC02005100FF 可行
8537102700C81D0000AFAD02005000FE 可行
2837102700C81D0000020002005000AB 不可行
A10与A11的和即A9大于FF呢,那不造成了要向A8进位?
这么坑爹的计算方法要是拿计算器按,再一个个填入MCT,浪费时间不说还容易算错。
A4 = A7 = A8 = A12 = A14 = "00"; A11 = "02";
a11 = 0x02;
a6 = 0x4b;
IDnM = raw_input("请输入学号与金额(例如:01 200):");
ID = IDnM [0:2];
Money = IDnM [3:]+"00"; #字符
Decmoney = int(Money,10); #十进制
Hexmoney = hex(Decmoney);
a2 = int(Hexmoney[4:6],16); #十六进制
a3 = int(Hexmoney[2:4],16); #十六进制
a1 = a2 + a3;
a5 = a1 ^ 0xff;
if a1 > 0xff: #A1此时验证是否大于0xFF
a10 = 0xfe;
a15 = 0x2ff - a1 - a6 - a10; #A15校验位
else: #A1此时验证是否小于0xFF
a10 = 0xec;
a15 = 0x1ff - a1 - a6 - a10; #A15校验位
a0 = a2 ^ a3 ^ a6 ^ a10 ^ a11; #A0校验位
a9 = a10 + a11;
a13 = a9 ^ 0xff;
print ID, "号当前金额为",IDnM [3:],"元";
print "10扇区对应数据为:";
A0 = hex(a0)[len(hex(a0))-2:];
A1 = hex(a1)[len(hex(a1))-2:];
A2 = hex(a2)[len(hex(a2))-2:];
A3 = hex(a3)[len(hex(a3))-2:];
A5 = hex(a5)[len(hex(a5))-2:];
A6 = hex(a6)[len(hex(a6))-2:];
A9 = hex(a9)[len(hex(a9))-2:];
A10 = hex(a10)[len(hex(a10))-2:];
A11 = "02";
A13 = hex(a13)[len(hex(a13))-2:];
A15 = hex(a15)[len(hex(a15))-2:];
data = A0+A1+A2+A3+A4+A5+A6+A7+A8+A9+A10+A11+A12+A13+A14+A15;
data=data.replace("x","0").upper();
print data;
f = open("card.txt","w"); #将数据写入同目录下的data.txt
print >>f,data;
f.close();
raw_input("输入回车键退出");
- 我的微信
- 这是我的微信扫一扫
- 我的微信公众号
- 我的微信公众号扫一扫