global hash func
Juan Batiz-Benet committed
Jul 5, 2014 at 15:13 UTC
61ac7191c4ba95248544e859de1d5c2707c6eecf
2 files changed
+7
-1
merkledag/merkledag.go
+1
-1
@@ -72,7 +72,7 @@ func (n *Node) Multihash() (mh.Multihash, error) {
72
return nil, err
73
}
74
75
- return mh.Sum(b, mh.SHA2_256, -1)
75
+ return u.Hash(b)
76
}
77
78
func (n *Node) Key() (u.Key, error) {
util/util.go
+6
@@ -2,6 +2,7 @@ package util
2
3
import (
4
"fmt"
5
+ mh "github.com/jbenet/go-multihash"
6
"os"
7
)
8
@@ -11,6 +12,11 @@ var NotImplementedError = fmt.Errorf("Error: not implemented yet.")
12
// a Key for maps. It's a string (rep of a multihash).
13
type Key string
14
15
+// global hash function. uses multihash SHA2_256, 256 bits
16
+func Hash(data []byte) (mh.Multihash, error) {
17
+ return mh.Sum(data, mh.SHA2_256, -1)
18
+}
19
+
20
// Shorthand printing functions.
21
func PErr(format string, a ...interface{}) {
22
fmt.Fprintf(os.Stderr, format, a...)