Note: This is taken from the Chicken Wiki, where a more recent version could be available.
= message-digest
Message Digest provides support for message digest primitives. A message-digest is a function taking arbitrary-length byte-block binary input and returning a fixed-length hash.
(require-extension message-digest)
[procedure] (make-binary-message-digest OBJECT CONTEXT-INFO DIGEST-LENGTH INIT UPDATE FINAL [ID])
Returns the message-digest for OBJECT as a binary string. ID is the symbol for the calling context.
Acceptable objects are string, input-port, blob, or anything that can be converted into a blob. Lists, vectors, and homogeneous-vectors can be converted. Lists and vectors should only be composed of characters, fixnums, or booleans. A boolean is treated as #f = 0 and #t = 1.
An input-port is not closed, but is read to end-of-file.
CONTEXT-INFO is either a procedure that returns an object, or a positive fixnum. When a fixnum a block of memory of length CONTEXT-INFO is allocated (and automatically free'ed). The CONTEXT can be a pointer object or any other Scheme object.
DIGEST-LENGTH The fixnum count of bytes in the result string.
The phase procedures:
[procedure] (INIT CONTEXT)
Initialization phase procedure. Sets up the CONTEXT, if necessary. The result is ignored.
[procedure] (UPDATE CONTEXT BYTES COUNT)
Accumulation phase procedure. Must accumulate the COUNT BYTES. BYTES is a Scheme non-immediate object. Will be called one or more times. The result is ignored.
See message-digest-chunk-size to set the number of bytes read per update invocation.
[procedure] (FINAL CONTEXT RESULT)
Finalization phase procedure. Must build the resulting message-digest in the supplied RESULT string. The result is ignored.
The optional ID is for identification. If not supplied a unique id will be generated.
[procedure] (make-message-digest OBJECT CONTEXT-INFO DIGEST-LENGTH INIT UPDATE FINAL [ID])
Exactly as above but returns the message-digest for OBJECT as a hexadecimal encoded string of length 2 * DIGEST-LENGTH.
[record] (message-digest-primitive CONTEXT-INFO DIGEST-LENGTH INIT UPDATE FINAL ID)
The meaning of the fields are exactly as above.
[procedure] message-digest? [procedure] message-digest-context-info [procedure] message-digest-digest-length [procedure] message-digest-init [procedure] message-digest-update [procedure] message-digest-final [procedure] message-digest-name
[procedure] (message-digest-primitive-apply MESSAGE-DIGEST-PRIMITIVE OBJECT [ID])
Returns a binary-message-digest of OBJECT using MESSAGE-DIGEST-PRIMITIVE.
[parameter] (message-digest-chunk-size [SIZE])
The number of bytes to read during the message-digest update phase. SIZE is a positive fixnum, default 1024.
[procedure] (byte-string->substring-list STRING CHUNK-SIZE [START [END]])
Returns a list of CHUNK-SIZE substrings of STRING, on the interval [START END). Defaults are [0 string-length). Any remaining substring less than chunk-size is appended to the list.
[procedure] (byte-string->substring-list/shared STRING CHUNK-SIZE [START [END]])
Returns a list of CHUNK-SIZE substrings of STRING, on the interval [START END). Defaults are [0 string-length). Any remaining substring less than chunk-size is appended to the list.
The substrings share storage with the STRING!
[procedure] (string->hexadecimal STRING [LENGTH])
Returns the STRING as a hex-encoded string. When LENGTH missing string-length is used. The returned string is 2 * string-length.
[procedure] (string->substring-list STRING CHUNK-SIZE [START [END]])
Returns a list of CHUNK-SIZE substrings of STRING, on the interval [START END). Defaults are [0 string-length). Any remaining substring less than chunk-size is appended to the list.
Byte Oriented!
[procedure] (string->substring-list/shared STRING CHUNK-SIZE [START [END]])
Returns a list of CHUNK-SIZE substrings of STRING, on the interval [START END). Defaults are [0 string-length). Any remaining substring less than chunk-size is appended to the list.
The substrings share storage with the STRING!
Byte Oriented!
[procedure] (->byte-vector OBJECT)
Converts the OBJECT into a byte-vector.
[procedure] (->blob OBJECT)
Converts the OBJECT into a blob.
Kon Lovett
Copyright © 2006, 2007 Kon Lovett. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the Software), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED ASIS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.