Ironclad internally works with byte arrays.
But it provides tools for converting from ascii strings to such arrays, and from bytes to โhexadecimalโ strings. Here is an interactive session (note that I know little about cryptographic algorithms):
CL-USER> (in-package :ironclad) #<PACKAGE "IRONCLAD">
Privacy Transformation:
CRYPTO> (ascii-string-to-byte-array "V0mn1LLQIc6GNSiBpDfDmRo3Ji8leBZWqMIolNBsnaklScgI") #(86 48 109 110 49 76 76 81 73 99 54 71 78 83 105 66 112 68 102 68 109 82 111 51 74 105 56 108 101 66 90 87 113 77 73 111 108 78 66 115 110 97 107 108 83 99 103 73)
Building HMAC from the previous value:
CRYPTO> (make-hmac * :sha256) #<HMAC(SHA256) {1006214D93}>
Now I'm not sure if this is what you want, but according to the documentation , you should update hmac with one or more sequences:
CRYPTO> (update-hmac * (ascii-string-to-byte-array "stupidstupid")) #<HMAC(SHA256) {1006214D93}>
... and then calculate the digest:
CRYPTO> (hmac-digest *)
The resulting array can be converted to the sixth line:
CRYPTO> (byte-array-to-hex-string *) "b25ae4f4f42d6da333de4debf4adf9d0902b7482d2bc3ef7919964c67756cfa3"
For completeness, here's how you could wrap these functions to replicate the source code, assuming you are in a package that imports the correct characters:
(defun hex (bytes) (byte-array-to-hex-string bytes)) (defun hmac_sha256 (secret text) (let ((hmac (make-hmac (ascii-string-to-byte-array secret) :sha256))) (update-hmac hmac (ascii-string-to-byte-array text)) (hmac-digest hmac)))
Finally:
(HEX (HMAC_SHA256 "V0mn1LLQIc6GNSiBpDfDmRo3Ji8leBZWqMIolNBsnaklScgI" "stupidstupid")) => "b25ae4f4f42d6da333de4debf4adf9d0902b7482d2bc3ef7919964c67756cfa3"