diff options
Diffstat (limited to 'internal/cryptoutil/sha1.go')
-rw-r--r-- | internal/cryptoutil/sha1.go | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/internal/cryptoutil/sha1.go b/internal/cryptoutil/sha1.go new file mode 100644 index 00000000..38133960 --- /dev/null +++ b/internal/cryptoutil/sha1.go @@ -0,0 +1,17 @@ +// Copyright 2020 The Gogs Authors. All rights reserved. +// Use of this source code is governed by a MIT-style +// license that can be found in the LICENSE file. + +package cryptoutil + +import ( + "crypto/sha1" + "encoding/hex" +) + +// SHA1 encodes string to hexadecimal of SHA1 checksum. +func SHA1(str string) string { + h := sha1.New() + _, _ = h.Write([]byte(str)) + return hex.EncodeToString(h.Sum(nil)) +} |