Skip to content

Commit

Permalink
modified hmac export pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
chaosBreaking committed Mar 13, 2019
1 parent df57b0f commit 8c777e4
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions hmac-sha3.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const str2Buf = S => {
}

function hmac (type = 224) {
if (!funcs[type]) throw new Error('Invalid function type')
if (!funcs[`sha${type}`]) throw new Error('Invalid function type')
let hash = funcs[`sha${type}`]
return (key, message) => {
message = Buffer.from(String(message))
Expand All @@ -50,4 +50,9 @@ function hmac (type = 224) {
}
}

module.exports = { hmac, str2Buf }
module.exports = {
hmac224: hmac(224),
hmac256: hmac(256),
hmac384: hmac(384),
hmac512: hmac(512),
}

0 comments on commit 8c777e4

Please sign in to comment.