-
Notifications
You must be signed in to change notification settings - Fork 0
/
blake256.go
49 lines (39 loc) · 1.04 KB
/
blake256.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 blake256
import "hash"
// New returns a new hash.Hash computing the BLAKE-256 checksum.
func New() hash.Hash {
return newDigest(256, iv256)
}
// NewWithSalt is like New but initializes salt with the given 16-byte slice.
func NewWithSalt(salt []byte) hash.Hash {
d := newDigest(256, iv256)
d.setSalt(salt)
return d
}
// Sum returns the BLAKE-256 checksum of the data.
func Sum(data []byte) (out [Size]byte) {
d := New()
d.Write(data)
sum := d.Sum(nil)
copy(out[:], sum)
return
}
// =======
// New224 returns a new hash.Hash computing the BLAKE-224 checksum.
func New224() hash.Hash {
return newDigest(224, iv224)
}
// New224WithSalt is like New224 but initializes salt with the given 16-byte slice.
func New224WithSalt(salt []byte) hash.Hash {
d := newDigest(224, iv224)
d.setSalt(salt)
return d
}
// Sum224 returns the BLAKE-224 checksum of the data.
func Sum224(data []byte) (out [Size224]byte) {
d := New224()
d.Write(data)
sum := d.Sum(nil)
copy(out[:], sum)
return
}