aboutsummaryrefslogtreecommitdiff
path: root/internal/cryptoutil/sha1.go
blob: 3813396060eeed9c2a4a78610ed18aa0de54e7ac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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))
}