-
Notifications
You must be signed in to change notification settings - Fork 0
/
shabal.go
100 lines (78 loc) · 1.88 KB
/
shabal.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
package shabal
import (
"hash"
)
// New returns a new hash.Hash computing the shabal checksum
func New(outSize int) (hash.Hash, error) {
return newDigest(outSize)
}
// ============
// New192 returns a new hash.Hash computing the shabal-192 checksum
func New192() hash.Hash {
h, _ := newDigest(192)
return h
}
// Sum192 returns the shabal-192 checksum of the data.
func Sum192(data []byte) (out [Size192]byte) {
h := New192()
h.Write(data)
sum := h.Sum(nil)
copy(out[:], sum)
return
}
// ============
// New224 returns a new hash.Hash computing the shabal-224 checksum
func New224() hash.Hash {
h, _ := newDigest(224)
return h
}
// Sum224 returns the shabal-224 checksum of the data.
func Sum224(data []byte) (out [Size224]byte) {
h := New224()
h.Write(data)
sum := h.Sum(nil)
copy(out[:], sum)
return
}
// ============
// New256 returns a new hash.Hash computing the shabal-256 checksum
func New256() hash.Hash {
h, _ := newDigest(256)
return h
}
// Sum256 returns the shabal-256 checksum of the data.
func Sum256(data []byte) (out [Size256]byte) {
h := New256()
h.Write(data)
sum := h.Sum(nil)
copy(out[:], sum)
return
}
// ============
// New384 returns a new hash.Hash computing the shabal-384 checksum
func New384() hash.Hash {
h, _ := newDigest(384)
return h
}
// Sum384 returns the shabal-384 checksum of the data.
func Sum384(data []byte) (out [Size384]byte) {
h := New384()
h.Write(data)
sum := h.Sum(nil)
copy(out[:], sum)
return
}
// ============
// New512 returns a new hash.Hash computing the shabal-512 checksum
func New512() hash.Hash {
h, _ := newDigest(512)
return h
}
// Sum512 returns the shabal-512 checksum of the data.
func Sum512(data []byte) (out [Size512]byte) {
h := New512()
h.Write(data)
sum := h.Sum(nil)
copy(out[:], sum)
return
}