aboutsummaryrefslogtreecommitdiff
path: root/types/util.go
diff options
context:
space:
mode:
Diffstat (limited to 'types/util.go')
-rw-r--r--types/util.go13
1 files changed, 13 insertions, 0 deletions
diff --git a/types/util.go b/types/util.go
new file mode 100644
index 0000000..dc8ccba
--- /dev/null
+++ b/types/util.go
@@ -0,0 +1,13 @@
+package types
+
+import (
+ "crypto/sha256"
+)
+
+func Hash(buf []byte) *[HashSize]byte {
+ var ret [HashSize]byte
+ hash := sha256.New()
+ hash.Write(buf)
+ copy(ret[:], hash.Sum(nil))
+ return &ret
+}