netbird/relay/messages/id.go
2024-05-23 13:24:02 +02:00

21 lines
382 B
Go

package messages
import (
"crypto/sha256"
"encoding/base64"
)
const (
IDSize = sha256.Size
)
func HashID(peerID string) ([]byte, string) {
idHash := sha256.Sum256([]byte(peerID))
idHashString := base64.StdEncoding.EncodeToString(idHash[:])
return idHash[:], idHashString
}
func HashIDToString(idHash []byte) string {
return base64.StdEncoding.EncodeToString(idHash[:])
}