Files
Gogs/internal/cryptoutil/sha.go
ᴊᴏᴇ ᴄʜᴇɴ 59e9fa191b chore: remove all MIT license file headers (#8083)
Co-authored-by: deepsource-autofix[bot] <62050782+deepsource-autofix[bot]@users.noreply.github.com>
2026-01-08 19:32:15 -05:00

22 lines
437 B
Go

package cryptoutil
import (
"crypto/sha1"
"crypto/sha256"
"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))
}
// SHA256 encodes string to hexadecimal of SHA256 checksum.
func SHA256(str string) string {
h := sha256.New()
_, _ = h.Write([]byte(str))
return hex.EncodeToString(h.Sum(nil))
}