aboutsummaryrefslogtreecommitdiff
path: root/peer/id.go
blob: 197da5abe2a369301ea57eb7b24d5830f2cda16c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
package peer

import (
	"crypto/rand"
	"fmt"
	"math/big"
)

func NewID() (string, error) {
	limit := new(big.Int).Lsh(big.NewInt(1), 80)
	id, err := rand.Int(rand.Reader, limit)
	if err != nil {
		return "", err
	}
	return fmt.Sprintf("%0.20x", id), nil
}