1 USING: help.markup help.syntax kernel math sequences quotations
2 math.private byte-arrays strings ;
6 { $class-description "The class of checksum algorithms." } ;
9 { $values { "seq" "a sequence" } { "str" "a string" } }
10 { $description "Converts a sequence of values from 0-255 to a string of hex numbers from 0-ff." }
12 { $example "USING: checksums io ;" "B{ 1 2 3 4 } hex-string print" "01020304" }
14 { $notes "Numbers are zero-padded on the left." } ;
17 { $values { "stream" "an input stream" } { "checksum" "a checksum specifier" } { "value" byte-array } }
18 { $contract "Computes the checksum of all data read from the stream." }
19 { $side-effects "stream" } ;
22 { $values { "bytes" "a sequence of bytes" } { "checksum" "a checksum specifier" } { "value" byte-array } }
23 { $contract "Computes the checksum of all data in a sequence." }
26 "USING: checksums checksums.crc32 prettyprint ;"
27 "B{ 1 10 100 } crc32 checksum-bytes ."
33 { $values { "lines" "a sequence of sequences of bytes" } { "checksum" "a checksum specifier" } { "value" byte-array } }
34 { $contract "Computes the checksum of all data in a sequence." }
37 "USING: checksums checksums.crc32 prettyprint ;"
39 "Take me out to the ball game"
40 "Take me out with the crowd"
41 } crc32 checksum-lines ."""
47 { $values { "path" "a pathname specifier" } { "checksum" "a checksum specifier" } { "value" byte-array } }
48 { $contract "Computes the checksum of all data in a file." }
51 "USING: checksums checksums.crc32 prettyprint ;"
52 """"resource:license.txt" crc32 checksum-file ."""
57 ARTICLE: "checksums" "Checksums"
58 "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."
60 "Checksums are instances of a class:"
61 { $subsections checksum }
62 "Operations on checksums:"
68 "Checksums should implement at least one of " { $link checksum-bytes } " and " { $link checksum-stream } ". Implementing " { $link checksum-lines } " is optional."
75 "Checksum implementations:"
76 { $subsections "checksums.crc32" }
77 { $vocab-subsection "MD5 checksum" "checksums.md5" }
78 { $vocab-subsection "SHA checksums" "checksums.sha" }
79 { $vocab-subsection "Adler-32 checksum" "checksums.adler-32" }
80 { $vocab-subsection "OpenSSL checksums" "checksums.openssl" } ;