-
Notifications
You must be signed in to change notification settings - Fork 0
/
whirlpool.go
54 lines (42 loc) · 998 Bytes
/
whirlpool.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
50
51
52
53
54
package whirlpool
import (
"hash"
)
// New returns a new hash.Hash computing the Whirlpool checksum.
func New() hash.Hash {
return newDigest(c, rc)
}
// Sum returns the Whirlpool checksum of the data.
func Sum(data []byte) (out [Size]byte) {
h := New()
h.Write(data)
sum := h.Sum(nil)
copy(out[:], sum)
return
}
// ========
// New0 returns a new hash.Hash computing the Whirlpool-0 checksum.
func New0() hash.Hash {
return newDigest(c0, rc0)
}
// Sum0 returns the Whirlpool-0 checksum of the data.
func Sum0(data []byte) (out [Size]byte) {
h := New0()
h.Write(data)
sum := h.Sum(nil)
copy(out[:], sum)
return
}
// ========
// New1 returns a new hash.Hash computing the Whirlpool-1 checksum.
func New1() hash.Hash {
return newDigest(c1, rc1)
}
// Sum1 returns the Whirlpool-1 checksum of the data.
func Sum1(data []byte) (out [Size]byte) {
h := New1()
h.Write(data)
sum := h.Sum(nil)
copy(out[:], sum)
return
}