Skip to content

Instantly share code, notes, and snippets.

@PuercoPop
Created March 29, 2014 05:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PuercoPop/9848953 to your computer and use it in GitHub Desktop.
Save PuercoPop/9848953 to your computer and use it in GitHub Desktop.
(defun to-auth-header (user &optional (date (http-date (now))))
"Encode a user's email, password and a timestamp with hmac."
(let* ((hmac (make-hmac *hmac-secret* :sha256))
(message (string-to-octets (format nil "~S ~S" (password user) date)))
(digest (progn
(update-hmac hmac message)
(hmac-digest hmac)))
(b64-digest (usb8-array-to-base64-string digest)))
(values (format nil "NOQ ~A:~A" (email user) b64-digest)
(format nil "Date: ~A" date))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment