Commit 42bb79f0 authored by Zach Beane's avatar Zach Beane
Browse files

Add MD5-INIT, MD5-UPDATE, MD5-FINAL.

parent fedb2906
...@@ -375,3 +375,37 @@ values otherwise." ...@@ -375,3 +375,37 @@ values otherwise."
(defmacro excl:push-atomic (value place) (defmacro excl:push-atomic (value place)
`(push ,value ,place )) `(push ,value ,place ))
;;; MD5
(defun excl:md5-init ()
(make-md5-state))
(defun excl:md5-update (state data &key (start 0) end external-format)
(when (stringp data)
(setf data (string-to-octets data
:external-format (or external-format :latin-1)
:start start
:end (or end (length data))))
(setf start 0)
(setf end (length data)))
(update-md5-state state data :start start :end end)
(values))
(defun excl:md5-final (state &key (return :integer))
(let ((result (finalize-md5-state state)))
(ecase return
(:usb8
result)
(:hex
(with-output-to-string (s)
(map nil (lambda (octet)
(format s "~2,'0X" octet))
result)))
(:integer
(let ((i 0))
(map nil (lambda (octet)
(setf i (logior (ash i 8) octet)))
result)
i)))))
...@@ -35,6 +35,10 @@ ...@@ -35,6 +35,10 @@
#:create-scanner #:create-scanner
#:scan #:scan
#:split) #:split)
(:import-from #:md5
#:make-md5-state
#:update-md5-state
#:finalize-md5-state)
(:import-from #:split-sequence (:import-from #:split-sequence
#:split-sequence) #:split-sequence)
(:import-from #:flexi-streams (:import-from #:flexi-streams
...@@ -133,6 +137,9 @@ ...@@ -133,6 +137,9 @@
#:then #:then
#:thenret #:thenret
#:else) #:else)
(:export #:md5-init
#:md5-update
#:md5-final)
(:export #:pop-atomic (:export #:pop-atomic
#:push-atomic #:push-atomic
#:single-channel-simple-stream #:single-channel-simple-stream
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment