FunctionPackage: exclToCDocOverviewCGDocRelNotesFAQIndexPermutedIndex
Allegro CL version 9.0
This page is new in 9.0.


Arguments: context &key return

You may need to evaluate (require :digest) to load the digest code before calling this function.

Compute and return the hash from context, in a format determined by the return keyword argument. digest-init returns a context (and you specify the hashing type in that call).

return can be one of the following values:

cl-user(4): (setq c (digest-init 'md5))
#(1 35 69 103 137 171 205 239 254 220 ...)
cl-user(5): (digest-update c "foo")
cl-user(6): (digest-final c :return :usb8)
#(172 189 24 219 76 194 248 92 237 239 ...)

;;  Potential problem with :return :integer (or :return unspecified
;;  as the default is :integer). The call is to DIGEST-FILE which calls
;;  DIGEST-FINAL and returns the value MD5-FINAL returns.
;;  Here we get the md5 value in a shell:
%  openssl dgst -md5 -hex cmp05-optdialog.jpg
MD5(cmp05-optdialog.jpg)= 03c6f3f0ede5188ac49c30e11e7afa4e

;; Now we get it with DIGEST-FILE:
cl-user(17): (digest-file 'md5 "~/cmp05-optdialog.jpg")
cl-user(18): (format t "~x" *)

;; Note the hex values are the same but the leading 0 is not printed
;; by Lisp, which is dealing with the value as an integer. The leading
;; 0 is preserved when the :return is :hex:
cl-user(21): (digest-file 'md5 "~/cmp05-optdialog.jpg" :return :hex)

See MD5, SHA*, HMAC, RC4, and other message digest support in miscellaneous.htm.

Copyright (c) 1998-2015, Franz Inc. Oakland, CA., USA. All rights reserved.
Documentation for Allegro CL version 9.0. This page is new in the 9.0 release.
Created 2010.1.21.

Allegro CL version 9.0
This page is new in 9.0.