-
Notifications
You must be signed in to change notification settings - Fork 0
/
ripemd.go
71 lines (55 loc) · 1.11 KB
/
ripemd.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package ripemd
import (
"hash"
)
func New128() hash.Hash {
return newDigest128()
}
// Sum128 returns checksum of the data.
func Sum128(data []byte) (sum [Size128]byte) {
h := New128()
h.Write(data)
hash := h.Sum(nil)
copy(sum[:], hash)
return
}
// ============
// New160 returns a new hash.Hash computing the checksum.
func New160() hash.Hash {
h := newDigest160()
return h
}
// Sum160 returns checksum of the data.
func Sum160(data []byte) (sum [Size160]byte) {
h := New160()
h.Write(data)
hash := h.Sum(nil)
copy(sum[:], hash)
return
}
// ============
func New256() hash.Hash {
h := newDigest256()
return h
}
// Sum256 returns checksum of the data.
func Sum256(data []byte) (sum [Size256]byte) {
h := New256()
h.Write(data)
hash := h.Sum(nil)
copy(sum[:], hash)
return
}
// ============
func New320() hash.Hash {
h := newDigest320()
return h
}
// Sum320 returns checksum of the data.
func Sum320(data []byte) (sum [Size320]byte) {
h := New320()
h.Write(data)
hash := h.Sum(nil)
copy(sum[:], hash)
return
}