sha1.go 399 B

1234567891011121314151617
  1. // Copyright 2020 The Gogs Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. package cryptoutil
  5. import (
  6. "crypto/sha1"
  7. "encoding/hex"
  8. )
  9. // SHA1 encodes string to hexadecimal of SHA1 checksum.
  10. func SHA1(str string) string {
  11. h := sha1.New()
  12. _, _ = h.Write([]byte(str))
  13. return hex.EncodeToString(h.Sum(nil))
  14. }