33 lines
335 B
Go
33 lines
335 B
Go
package hash
|
|
|
|
import (
|
|
"crypto/sha1"
|
|
"hash"
|
|
)
|
|
|
|
type (
|
|
Sha1 struct {
|
|
d hash.Hash
|
|
}
|
|
)
|
|
|
|
func (s *Sha1) String() string {
|
|
return "sha1"
|
|
}
|
|
|
|
func (s *Sha1) Append(data []byte) {
|
|
if s.d == nil {
|
|
s.d = sha1.New()
|
|
}
|
|
|
|
s.d.Write(data)
|
|
}
|
|
|
|
func (s *Sha1) Finish() []byte {
|
|
if s.d == nil {
|
|
s.d = sha1.New()
|
|
}
|
|
|
|
return s.d.Sum(nil)
|
|
}
|