Skip to content

Commit 026ecd9

Browse files
committed
Added hash method
1 parent 68453d9 commit 026ecd9

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

pkg/types/hash.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package types
2+
3+
import (
4+
"crypto/sha256"
5+
"encoding/hex"
6+
)
7+
8+
///////////////////////////////////////////////////////////////////////////////
9+
// PUBLIC METHODS
10+
11+
func Hash(data []byte) string {
12+
// Return the SHA256 hash of the data
13+
h := sha256.New()
14+
h.Write(data)
15+
return hex.EncodeToString(h.Sum(nil))
16+
}

0 commit comments

Comments
 (0)