2008-05-08 20:36:44 -04:00
|
|
|
! Copyright (C) 2008 Doug Coleman.
|
|
|
|
! See http://factorcode.org/license.txt for BSD license.
|
|
|
|
USING: checksums classes.singleton kernel math math.ranges
|
|
|
|
math.vectors sequences ;
|
|
|
|
IN: checksums.adler-32
|
|
|
|
|
|
|
|
SINGLETON: adler-32
|
|
|
|
|
2009-02-22 20:13:08 -05:00
|
|
|
CONSTANT: adler-32-modulus 65521
|
2008-05-08 20:36:44 -04:00
|
|
|
|
|
|
|
M: adler-32 checksum-bytes ( bytes checksum -- value )
|
|
|
|
drop
|
2009-05-17 18:50:31 -04:00
|
|
|
[ sum 1 + ]
|
2008-05-08 20:36:44 -04:00
|
|
|
[ [ dup length [1,b] <reversed> v. ] [ length ] bi + ] bi
|
|
|
|
[ adler-32-modulus mod ] bi@ 16 shift bitor ;
|