checksums: Really fix... only add the number of extra bytes in the last unchecksummed block.

char-rename
Doug Coleman 2016-07-09 14:17:59 -05:00
parent 2c5a2e9600
commit d6d4e0e903
2 changed files with 2 additions and 2 deletions

View File

@ -50,7 +50,7 @@ GENERIC: get-checksum ( checksum-state -- value )
] while
>byte-vector >>bytes
] keep
length [ + ] curry change-bytes-read ;
length 64 mod [ + ] curry change-bytes-read ;
: add-checksum-stream ( checksum-state stream -- checksum-state )
[ [ add-checksum-bytes ] each-block ] with-input-stream ;

View File

@ -73,5 +73,5 @@ CONSTANT: bytes-a B{ 0 1 0 0 0 0 0 0 }
CONSTANT: bytes-b B{ 1 2 3 4 5 6 7 8 }
{ t } [
sha1 initialize-checksum-state bytes-a bytes-b append add-checksum-bytes get-checksum
sha1 initialize-checksum-state bytes-a add-checksum-bytes bytes-b add-checksum-bytes get-checksum
sha1 initialize-checksum-state bytes-a add-checksum-bytes bytes-b add-checksum-bytes get-checksum =
] unit-test