Skip to content

Commit

Permalink
fix: don't panic when sha256-hashing
Browse files Browse the repository at this point in the history
  • Loading branch information
alnr committed Jun 15, 2023
1 parent e9f5efe commit 7653936
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions metricsx/middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,8 @@ type Service struct {

// Hash returns a hashed string of the value.
func Hash(value string) string {
hash := sha256.New()
_, err := hash.Write([]byte(value))
if err != nil {
panic("unable to hash value")
}
return hex.EncodeToString(hash.Sum(nil))
sha := sha256.Sum256([]byte(value))
return hex.EncodeToString(sha[:])
}

// Options configures the metrics service.
Expand Down

0 comments on commit 7653936

Please sign in to comment.