Created
March 29, 2014 05:20
-
-
Save PuercoPop/9848953 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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