2014-05-23 17:24:04 -04:00
USING: byte-arrays help.markup help.syntax sequences strings ;
2008-04-30 17:11:55 -04:00
IN: checksums
HELP: checksum
{ $class-description "The class of checksum algorithms." } ;
HELP: checksum-stream
{ $values { "stream" "an input stream" } { "checksum" "a checksum specifier" } { "value" byte-array } }
{ $contract "Computes the checksum of all data read from the stream." }
{ $side-effects "stream" } ;
HELP: checksum-bytes
{ $values { "bytes" "a sequence of bytes" } { "checksum" "a checksum specifier" } { "value" byte-array } }
2009-09-30 03:26:32 -04:00
{ $contract "Computes the checksum of all data in a sequence." }
{ $examples
{ $example
"USING: checksums checksums.crc32 prettyprint ;"
"B{ 1 10 100 } crc32 checksum-bytes ."
"B{ 78 179 254 238 }"
}
} ;
2008-04-30 17:11:55 -04:00
HELP: checksum-lines
{ $values { "lines" "a sequence of sequences of bytes" } { "checksum" "a checksum specifier" } { "value" byte-array } }
2009-09-30 03:26:32 -04:00
{ $contract "Computes the checksum of all data in a sequence." }
{ $examples
{ $example
"USING: checksums checksums.crc32 prettyprint ;"
2015-07-26 01:59:56 -04:00
"{
\"Take me out to the ball game\"
\"Take me out with the crowd\"
} crc32 checksum-lines ."
2009-09-30 03:26:32 -04:00
"B{ 111 205 9 27 }"
}
} ;
2008-04-30 17:11:55 -04:00
HELP: checksum-file
{ $values { "path" "a pathname specifier" } { "checksum" "a checksum specifier" } { "value" byte-array } }
2016-06-26 08:07:32 -04:00
{ $description "Computes the checksum of all data in a file." }
2009-09-30 03:26:32 -04:00
{ $examples
{ $example
"USING: checksums checksums.crc32 prettyprint ;"
2016-03-17 05:36:34 -04:00
"\"resource:LICENSE.txt\" crc32 checksum-file ."
2009-09-30 03:26:32 -04:00
"B{ 100 139 199 92 }"
}
} ;
2008-04-30 17:11:55 -04:00
ARTICLE: "checksums" "Checksums"
"A " { $emphasis "checksum" } " is a function mapping sequences of bytes to fixed-length strings. While checksums are not one-to-one, a good checksum should have a low probability of collision. Additionally, some checksum algorithms are designed to be hard to reverse, in the sense that finding an input string which hashes to a given checksum string requires a brute-force search."
$nl
"Checksums are instances of a class:"
2009-10-01 15:56:36 -04:00
{ $subsections checksum }
2008-04-30 17:11:55 -04:00
"Operations on checksums:"
2009-10-01 15:56:36 -04:00
{ $subsections
checksum-bytes
checksum-stream
checksum-lines
2016-07-30 12:31:10 -04:00
checksum-file
2009-10-01 15:56:36 -04:00
}
2008-04-30 17:11:55 -04:00
"Checksums should implement at least one of " { $link checksum-bytes } " and " { $link checksum-stream } ". Implementing " { $link checksum-lines } " is optional."
$nl
2016-07-30 12:31:10 -04:00
"Checksums can also implement a stateful checksum protocol that allows users to push bytes when needed and then at a later point request the checksum value. The default implementation is not very efficient, storing all of the bytes and then calling " { $link checksum-bytes } " when " { $link get-checksum } " is requested."
$nl
2009-10-01 15:56:36 -04:00
{ $subsections
2016-07-30 12:31:10 -04:00
initialize-checksum-state
add-checksum-bytes
add-checksum-stream
add-checksum-lines
add-checksum-file
get-checksum
2009-10-01 15:56:36 -04:00
}
2008-04-30 17:11:55 -04:00
"Checksum implementations:"
2016-07-30 12:31:10 -04:00
{ $vocab-subsection "CRC32 checksum" "checksums.crc32" }
2008-04-30 17:11:55 -04:00
{ $vocab-subsection "MD5 checksum" "checksums.md5" }
2009-05-17 18:58:36 -04:00
{ $vocab-subsection "SHA checksums" "checksums.sha" }
2008-05-11 18:42:48 -04:00
{ $vocab-subsection "Adler-32 checksum" "checksums.adler-32" }
2015-07-02 13:31:22 -04:00
{ $vocab-subsection "OpenSSL checksums" "checksums.openssl" }
2016-06-26 08:00:52 -04:00
{ $vocab-subsection "Internet checksum" "checksums.internet" }
{ $vocab-subsection "Checksum using an external utility" "checksums.process" } ;
2008-05-11 18:42:48 -04:00
ABOUT: "checksums"