prometheus-fail2ban-exporter/auth/hash.go

19 lines
262 B
Go
Raw Permalink Normal View History

2023-10-02 10:50:34 +00:00
package auth
import (
"crypto/sha256"
"encoding/hex"
)
func hash(data []byte) []byte {
if len(data) == 0 {
return []byte{}
}
b := sha256.Sum256(data)
return b[:]
}
func HashString(data string) string {
return hex.EncodeToString(hash([]byte(data)))
}