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