/
sha.go
138 lines (96 loc) · 1.9 KB
/
sha.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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
package hash
import (
"crypto/sha1"
"crypto/sha256"
"crypto/sha512"
)
// SHA1 哈希值
func (this Hash) SHA1() Hash {
h := sha1.New()
h.Write(this.data)
this.data = h.Sum(nil)
return this
}
// NewSHA1
func (this Hash) NewSHA1() Hash {
this.hash = sha1.New()
return this
}
// ===========
// SHA224 哈希值
func (this Hash) SHA224() Hash {
h := sha256.New224()
h.Write(this.data)
this.data = h.Sum(nil)
return this
}
// NewSHA224
func (this Hash) NewSHA224() Hash {
this.hash = sha256.New224()
return this
}
// ===========
// SHA256 哈希值
func (this Hash) SHA256() Hash {
h := sha256.New()
h.Write(this.data)
this.data = h.Sum(nil)
return this
}
// NewSHA256
func (this Hash) NewSHA256() Hash {
this.hash = sha256.New()
return this
}
// ===========
// SHA384 哈希值
func (this Hash) SHA384() Hash {
h := sha512.New384()
h.Write(this.data)
this.data = h.Sum(nil)
return this
}
// NewSHA384
func (this Hash) NewSHA384() Hash {
this.hash = sha512.New384()
return this
}
// ===========
// SHA512 哈希值
func (this Hash) SHA512() Hash {
h := sha512.New()
h.Write(this.data)
this.data = h.Sum(nil)
return this
}
// NewSHA512
func (this Hash) NewSHA512() Hash {
this.hash = sha512.New()
return this
}
// ===========
// SHA512_224 哈希值
func (this Hash) SHA512_224() Hash {
h := sha512.New512_224()
h.Write(this.data)
this.data = h.Sum(nil)
return this
}
// NewSHA512_224
func (this Hash) NewSHA512_224() Hash {
this.hash = sha512.New512_224()
return this
}
// ===========
// SHA512_256 哈希值
func (this Hash) SHA512_256() Hash {
h := sha512.New512_256()
h.Write(this.data)
this.data = h.Sum(nil)
return this
}
// NewSHA512_256
func (this Hash) NewSHA512_256() Hash {
this.hash = sha512.New512_256()
return this
}