hash.go 294 B

1234567891011121314151617181920
  1. package crypt
  2. import (
  3. "crypto/sha512"
  4. "io"
  5. "github.com/pkg/errors"
  6. )
  7. func GetKey(r io.Reader) ([]byte, error) {
  8. h := sha512.New512_256()
  9. _, err := io.Copy(h, r)
  10. if err != nil {
  11. return nil, errors.Wrap(err, "GetKey: could not copy data in the hasher")
  12. }
  13. return h.Sum(nil), nil
  14. }