Skip to content

Instantly share code, notes, and snippets.

@ppsdatta
Created June 20, 2021 19:02
Show Gist options
  • Save ppsdatta/c71a5be1661d7ae838e951977278c548 to your computer and use it in GitHub Desktop.
Save ppsdatta/c71a5be1661d7ae838e951977278c548 to your computer and use it in GitHub Desktop.
Generate hmac with sha256 in Common Lisp
(ql:quickload :ironclad)
(defpackage :test (:use :cl :ironclad))
(in-package :test)
(defun hmac-sha256 (secret data)
(let* ((secret-bytes (ascii-string-to-byte-array secret))
(data-bytes (ascii-string-to-byte-array data))
(h (make-hmac secret-bytes :sha256)))
(update-hmac h data-bytes)
(byte-array-to-hex-string (hmac-digest h))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment