netbird/signal/fingerprint.go

20 lines
350 B
Go
Raw Normal View History

2021-05-01 12:45:37 +02:00
package signal
import (
"crypto/sha256"
"encoding/hex"
)
const (
// HexTable Table of Hexadecimal chars
2021-05-01 12:45:37 +02:00
HexTable = "0123456789abcdef"
)
// FingerPrint generates a SHA256 Fingerprint of the string
2021-05-01 12:45:37 +02:00
func FingerPrint(key string) string {
hasher := sha256.New()
hasher.Write([]byte(key))
sha := hasher.Sum(nil)
return hex.EncodeToString(sha)
}