add examples to checksums docs
parent
0b0a2c5ce4
commit
bc5807b20a
|
@ -20,15 +20,39 @@ HELP: checksum-stream
|
|||
|
||||
HELP: checksum-bytes
|
||||
{ $values { "bytes" "a sequence of bytes" } { "checksum" "a checksum specifier" } { "value" byte-array } }
|
||||
{ $contract "Computes the checksum of all data in a sequence." } ;
|
||||
{ $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 }"
|
||||
}
|
||||
} ;
|
||||
|
||||
HELP: checksum-lines
|
||||
{ $values { "lines" "a sequence of sequences of bytes" } { "checksum" "a checksum specifier" } { "value" byte-array } }
|
||||
{ $contract "Computes the checksum of all data in a sequence." } ;
|
||||
{ $contract "Computes the checksum of all data in a sequence." }
|
||||
{ $examples
|
||||
{ $example
|
||||
"USING: checksums checksums.crc32 prettyprint ;"
|
||||
"""{
|
||||
"Take me out to the ball game"
|
||||
"Take me out with the crowd"
|
||||
} crc32 checksum-lines ."""
|
||||
"B{ 111 205 9 27 }"
|
||||
}
|
||||
} ;
|
||||
|
||||
HELP: checksum-file
|
||||
{ $values { "path" "a pathname specifier" } { "checksum" "a checksum specifier" } { "value" byte-array } }
|
||||
{ $contract "Computes the checksum of all data in a file." } ;
|
||||
{ $contract "Computes the checksum of all data in a file." }
|
||||
{ $examples
|
||||
{ $example
|
||||
"USING: checksums checksums.crc32 prettyprint ;"
|
||||
""""resource:license.txt" crc32 checksum-file ."""
|
||||
"B{ 100 139 199 92 }"
|
||||
}
|
||||
} ;
|
||||
|
||||
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."
|
||||
|
|
Loading…
Reference in New Issue