buddy-core icon indicating copy to clipboard operation
buddy-core copied to clipboard

Feature Request - Support :hmac-sha1

Open bpringe opened this issue 7 years ago • 4 comments

I tried running the following but it appears there is no method implementation for :hmac-sha1. Will this be added?

(mac/hash payload {:key my-secret :alg :hmac+sha1})

I get an exception:

No method in multimethod 'engine' for dispatch value: :hmac+sha1

And I see that the method does not exist in the source.

bpringe avatar Oct 17 '18 00:10 bpringe

Quickest way to achieve this is to add new dispatch to multimethod, like this:

(defmethod mac/engine :hmac+sha1
  [options]
  (let [digest (hash/resolve-digest-engine
                 (:digest options :sha1))]
    (assert digest "Invalid digest engine.")
    (org.bouncycastle.crypto.macs.HMac. digest)))

It can be done outside of library in your own code, so you don't need to wait for new release :)

shilder avatar Oct 17 '18 06:10 shilder

PR is welcome ;)

niwinz avatar Oct 17 '18 07:10 niwinz

Sure, #59

shilder avatar Oct 17 '18 08:10 shilder

Wow, thanks for the quick responses and the PR!

bpringe avatar Oct 17 '18 15:10 bpringe