aboutsummaryrefslogtreecommitdiff
path: root/peer/id.go
blob: 641fca6635bf86e18958cec47dec124ca33cba30 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
package peer

import (
	"crypto/rand"
	"encoding/hex"
)

func NewID() []byte {
	src := make([]byte, 10)
	dst := make([]byte, hex.EncodedLen(len(src)))
	rand.Read(src)
	hex.Encode(dst, src)
	return dst
}

func NewIDFixed() [20]byte {
	ret := [20]byte{}
	copy(ret[:], NewID())
	return ret
}