vocabulary any console utility can be used to checksum data, provided it supports a certain interface: it should accept input data on STDIN and output result to STDOUT. The output should consist of the hexadecimal checksum string, terminated with a
character. For instance, all the checksums from the GNU CoreUtils package support this mode of operation as the default.
tuple holds a launch descriptor (see
) of the utility, e.g. "sha1sum". When the
method is called on it, a new instance of the checksum utility is started in the background. In Factor it is represented by the
tuple. You can then use
to stream data to it. When done, call
to read the resulting checksum and dispose of the tuple in one step. If you want to cancel the work without calling
, you must
of the tuple so that the underlying process is terminated.
methods encapsulate the above protocol, including instantiation and disposal of the
USING: byte-arrays checksums checksums.process ;
"test" >byte-array "sha1sum" <checksum-process> checksum-bytes .
169 74 143 229 204 177 155 166 28 76 8 115 211 145 233 135
152 47 187 211
USING: checksums checksums.common checksums.process
io io.encodings.binary namespaces ;
"LICENSE.txt" binary [
input-stream get "sha1sum" <checksum-process> checksum-stream
] with-file-reader .
125 80 102 9 175 178 81 111 33 59 33 149 187 70 193 32 81
188 89 156
This documentation was generated offline from a
load-all image. If you want, you can also
browse the documentation from within the
UI developer tools. See
the Factor website
for more information.
Factor 0.99 x86.64 (2203, heads/master-424edf64aa, Mar 8 2023 13:48:50)