]> gitweb.factorcode.org Git - factor.git/commitdiff
checksums: Really fix... only add the number of extra bytes in the last unchecksummed...
authorDoug Coleman <doug.coleman@gmail.com>
Sat, 9 Jul 2016 19:17:59 +0000 (14:17 -0500)
committerDoug Coleman <doug.coleman@gmail.com>
Sat, 9 Jul 2016 19:17:59 +0000 (14:17 -0500)
basis/checksums/common/common.factor
basis/checksums/sha/sha-tests.factor

index aaa2e9735776abd469b6073e6545e2cb646283dd..77be6761f701a50583938419fd25de419a6d3eca 100644 (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 ;
index 08be4db7779c8ca66d61d055ca7bedea6885d545..982a2caf171218aa000d26dbbc4d26a1ae58ffbb 100644 (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