mirror of
https://github.com/netbirdio/netbird.git
synced 2024-12-15 03:11:02 +01:00
21 lines
379 B
Go
21 lines
379 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)
|
|
}
|