12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- package hash
- import (
- "crypto/sha1"
- "crypto/sha256"
- "crypto/sha512"
- )
- // SHA1 sha1 hash
- func SHA1(bs []byte) (hs []byte, err error) {
- h := sha1.New()
- _, err = h.Write(bs)
- if err != nil {
- return
- }
- hs = h.Sum(nil)
- return
- }
- // SHA256 sha256 hash
- func SHA256(bs []byte) (hs []byte, err error) {
- h := sha256.New()
- _, err = h.Write(bs)
- if err != nil {
- return
- }
- hs = h.Sum(nil)
- return
- }
- // SHA512 sha512 hash
- func SHA512(bs []byte) (hs []byte, err error) {
- h := sha512.New()
- _, err = h.Write(bs)
- if err != nil {
- return
- }
- hs = h.Sum(nil)
- return
- }
|