Skip to content

Instantly share code, notes, and snippets.

@st
Created July 6, 2015 16:43
Show Gist options
  • Save st/d52ae86b8ddb83a6f6b4 to your computer and use it in GitHub Desktop.
Save st/d52ae86b8ddb83a6f6b4 to your computer and use it in GitHub Desktop.
hmac verify with String signature
(-> (hmac/hash "foo bar" "mysecretkey" :sha256)
(codecs/bytes->hex))
=> "61849448bdbb67b39d609471eead667e65b0d1b9e01b1c3bf7aa56b83e9c8083"
;; so far, so good
(hmac/verify "foo bar" "61849448bdbb67b39d609471eead667e65b0d1b9e01b1c3bf7aa56b83e9c8083" "mysecretkey" :sha256)
=> false
;; should be true, no?
(def bytes-hash (hmac/hash "foo bar" "mysecretkey" :sha256))
=> #'user/bytes-hash
(hmac/verify "foo bar" bytes-hash "mysecretkey" :sha256)
=> true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment