-
Notifications
You must be signed in to change notification settings - Fork 0
/
blake512.go
49 lines (39 loc) · 1.04 KB
/
blake512.go
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package blake512
import "hash"
// New returns a new hash.Hash computing the BLAKE-512 checksum.
func New() hash.Hash {
return newDigest(64, iv512)
}
// NewWithSalt is like New but initializes salt with the given 32-byte slice.
func NewWithSalt(salt []byte) hash.Hash {
d := newDigest(64, iv512)
d.setSalt(salt)
return d
}
// Sum returns the BLAKE-512 checksum of the data.
func Sum(data []byte) (out [Size]byte) {
d := New()
d.Write(data)
sum := d.Sum(nil)
copy(out[:], sum)
return
}
// ==========
// New384 returns a new hash.Hash computing the BLAKE-384 checksum.
func New384() hash.Hash {
return newDigest(48, iv384)
}
// New384WithSalt is like New384 but initializes salt with the given 32-byte slice.
func New384WithSalt(salt []byte) hash.Hash {
d := newDigest(48, iv384)
d.setSalt(salt)
return d
}
// Sum384 returns the BLAKE-384 checksum of the data.
func Sum384(data []byte) (out [Size384]byte) {
d := New384()
d.Write(data)
sum := d.Sum(nil)
copy(out[:], sum)
return
}