Python konzultace

Michal Ceresna ceresna na sturak.sk
Středa Leden 10 15:52:12 CET 2001


dobry den,
napriklad takto:

import os
import array

s0= "./a.bin"
s1= open(s0, "rb")
s2= os.path.getsize(s0)
image=array.array('b')
image.fromfile(s1,s2)
s1.close()
crc= 0xffff
 
hash16=[
0x0000, 0xCC01, 0xD801, 0x1400, 0xF001, 0x3C00, 0x2800, 0xE401,
0xA001, 0x6C00, 0x7800, 0xB401, 0x5000, 0x9C01, 0x8801, 0x4400
]
 
for b in image:
  crc= hash16[(b ^ crc) & 0xf] ^ (crc >> 4)
  crc= hash16[(b>>4 ^ crc) & 0xf] ^ (crc >> 4)
 
print 'crc: 0x%04X' % crc

-- 
Michal Ceresna, student of mffuk, Bratislava
Michal.Ceresna na st.fmph.uniba.sk


Další informace o konferenci Linux