Skip to content

Commit

Permalink
Expose NewHasher
Browse files Browse the repository at this point in the history
  • Loading branch information
tystuyfzand committed Jul 8, 2023
1 parent e840207 commit 43c09f0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions hub.go
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ func (h *Hub) callCallback(job PublishJob) bool {
}

if job.Subscription.Secret != "" {
mac := hmac.New(newHash(h.hasher), []byte(job.Subscription.Secret))
mac := hmac.New(NewHasher(h.hasher), []byte(job.Subscription.Secret))
mac.Write(job.Data)
req.Header.Set("X-Hub-Signature", h.hasher+"="+hex.EncodeToString(mac.Sum(nil)))
}
Expand Down Expand Up @@ -487,8 +487,8 @@ func (h *Hub) callCallback(job PublishJob) bool {
return false
}

// newHash takes a string and returns a hash.Hash based on type.
func newHash(hasher string) func() hash.Hash {
// NewHasher takes a string and returns a hash.Hash based on type.
func NewHasher(hasher string) func() hash.Hash {
switch hasher {
case "sha1":
return sha1.New
Expand Down
2 changes: 1 addition & 1 deletion publish.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func Notify(client *http.Client, job PublishJob) (bool, error) {
}

if job.Subscription.Secret != "" {
mac := hmac.New(newHash(job.Hub.Hasher), []byte(job.Subscription.Secret))
mac := hmac.New(NewHasher(job.Hub.Hasher), []byte(job.Subscription.Secret))
mac.Write(job.Data)
req.Header.Set("X-Hub-Signature", job.Hub.Hasher+"="+hex.EncodeToString(mac.Sum(nil)))
}
Expand Down

0 comments on commit 43c09f0

Please sign in to comment.