-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhash_sum.go
67 lines (51 loc) · 949 Bytes
/
hash_sum.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
package hash
import (
"hash"
)
// Write
func (this Hash) Write(p []byte) Hash {
this.hash.Write(p)
return this
}
// WriteString
func (this Hash) WriteString(s string) Hash {
p := []byte(s)
this.hash.Write(p)
return this
}
// Sum
func (this Hash) Sum(in []byte) Hash {
this.data = this.hash.Sum(in)
return this
}
// Sum32
func (this Hash) Sum32() uint32 {
if hash32, ok := this.hash.(hash.Hash32); ok {
return hash32.Sum32()
}
return 0
}
// Sum64
func (this Hash) Sum64() uint64 {
if hash64, ok := this.hash.(hash.Hash64); ok {
return hash64.Sum64()
}
return 0
}
// Reset
func (this Hash) Reset() Hash {
this.hash.Reset()
return this
}
// Size
func (this Hash) Size() int {
return this.hash.Size()
}
// BlockSize
func (this Hash) BlockSize() int {
return this.hash.BlockSize()
}
// Hash
func (this Hash) Hash() hash.Hash {
return this.hash
}