add adler-32 checksum, tests, and docs
parent
0ea519364a
commit
ce76b1888e
|
@ -0,0 +1,11 @@
|
||||||
|
USING: help.markup help.syntax ;
|
||||||
|
IN: checksums.adler-32
|
||||||
|
|
||||||
|
HELP: adler-32
|
||||||
|
{ $description "Adler-32 checksum algorithm." } ;
|
||||||
|
|
||||||
|
ARTICLE: "checksums.adler-32" "Adler-32 checksum"
|
||||||
|
"The Adler-32 checksum algorithm implements simple and fast checksum. It is used in zlib and rsync."
|
||||||
|
{ $subsection adler-32 } ;
|
||||||
|
|
||||||
|
ABOUT: "checksums.adler-32"
|
|
@ -0,0 +1,5 @@
|
||||||
|
USING: checksums.adler-32 checksums strings tools.test ;
|
||||||
|
IN: checksums.adler-32.tests
|
||||||
|
|
||||||
|
[ 300286872 ] [ "Wikipedia" adler-32 checksum-bytes ] unit-test
|
||||||
|
[ 2679885283 ] [ 10000 CHAR: a <string> adler-32 checksum-bytes ] unit-test
|
|
@ -0,0 +1,15 @@
|
||||||
|
! 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
|
||||||
|
|
||||||
|
: adler-32-modulus 65521 ; inline
|
||||||
|
|
||||||
|
M: adler-32 checksum-bytes ( bytes checksum -- value )
|
||||||
|
drop
|
||||||
|
[ sum 1+ ]
|
||||||
|
[ [ dup length [1,b] <reversed> v. ] [ length ] bi + ] bi
|
||||||
|
[ adler-32-modulus mod ] bi@ 16 shift bitor ;
|
|
@ -0,0 +1 @@
|
||||||
|
Doug Coleman
|
Loading…
Reference in New Issue