FunctionPackage: exclToCDocOverviewCGDocRelNotesFAQIndexPermutedIndex
Allegro CL version 9.0
Moderately revised from 8.2.
8.2 version


Arguments: context &key return

Finalize and return the SHA256 hash from context in a format determined by the return keyword argument.

return can be one of the following values:

cl-user(4): (setq c (sha256-init))
#S(excl::md-context :ctx 9183616 :size 32)
cl-user(5): (sha256-update c "foo")
cl-user(6): (sha256-final c :return :usb8)
#(44 38 180 107 104 255 198 143 249 155 ...)

;;  Potential problem with :return :integer (or :return unspecified
;;  as the default is :integer). The call is to SHA256-FILE which calls
;;  SHA256-FINAL and returns the value SHA256-FINAL returns.
;;  Here we get the sha256 value in a shell:
% openssl dgst -sha256 -hex tab-order.jpg 
SHA256(tab-order.jpg)= 079331d027a95cc63d1466fdf859e0c6b83532199e1c935f30a658bf8e5f8e29

;; Now we get it with SHA256-FILE:
cl-user(17): (sha256-file "~/tab-order.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): (sha256-file "~/tab-order.jpg" :return :hex)

See MD*, SHA*, HMAC, and other message digest support in miscellaneous.htm. See also digest-final.

Copyright (c) 1998-2017, Franz Inc. Oakland, CA., USA. All rights reserved.
This page has had moderate revisions compared to the 8.2 page.
Created 2017.2.15.

Allegro CL version 9.0
Moderately revised from 8.2.
8.2 version