blob: 0fe7c7ef8aea0f93c0d4a11db69019140104aec3 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
package crypto
import (
"crypto/sha512"
"gnunet/util"
)
// HashCode is the result of a 512-bit hash function (SHA-512)
type HashCode struct {
Bits []byte `size:"64"`
}
// NewHashCode creates a new, uninitalized hash value
func NewHashCode() *HashCode {
return &HashCode{
Bits: make([]byte, 64),
}
}
// Hash returns the SHA-512 hash value of a given blob
func Hash(data []byte) *HashCode {
val := sha512.Sum512(data)
return &HashCode{
Bits: util.Clone(val[:]),
}
}
|