checksum/hash/sha512.go

33 lines
351 B
Go

package hash
import (
"crypto/sha512"
"hash"
)
type (
Sha512 struct {
d hash.Hash
}
)
func (s *Sha512) String() string {
return "sha512"
}
func (s *Sha512) Append(data []byte) {
if s.d == nil {
s.d = sha512.New()
}
s.d.Write(data)
}
func (s *Sha512) Finish() []byte {
if s.d == nil {
s.d = sha512.New()
}
return s.d.Sum(nil)
}