CRC16 なんかを。

「奥村 晴彦氏著「アルゴリズム辞典」の公開ソース」のパチもんのパチもん。


#import psyco
def crc16( iStreamLength, sStream, iCRCPOLY = 0x1021, iStartValue = 0xFFFF ) :
 redundancy = iStartValue
 for i in xrange(iStreamLength) :
  redundancy = redundancy ^ ord( sStream[i] ) << 8
  for x in range(0,8) :
   tmp = redundancy << 1
   if redundancy & 0x8000 :
    tmp = tmp ^ iCRCPOLY
   redundancy = tmp
 return ~ redundancy & 0XFFFF
#psyco.bind(crc16)

1byte = 8bitと決め付けてみる。7とか9とかに持っていって使うよーな人は自力でCRCなんて書けるので知ったこっちゃない。実はint=32bitって決め打ちがあるみたいだから、

for x in range(0,8) :
 redundancy = redundancy << 1
 if redundancy & 0x10000 :
  redundancy = redundancy ^ iCRCPOLY

とか書けるかも。
手動アセンブルより、psycoの方が早いので、おまけ。導入してればコメントを外すだけで5倍は早くなる。
エラーチェックは全くしない。知ったこっちゃない。自分を信じる方が精神衛生上好ましい。と、プログラマーの憂鬱様に書いてあるし。

iStreamLengthの代わりにlen(sStream)でも動くと思う。