arnaucube
arnaucube/tor-eth-online-shopPublic Self-hosted repository
tor-eth-online-shop/utils.go
utils.goRaw
 1package main
 2
 3import (
 4	"crypto/rand"
 5	"math/big"
 6)
 7
 8func generateChallenge(length int) (string, error) {
 9	result := ""
10	for {
11		if len(result) >= length {
12			return result, nil
13		}
14		num, err := rand.Int(rand.Reader, big.NewInt(int64(127)))
15		if err != nil {
16			return "", err
17		}
18		n := num.Int64()
19		if n > 32 && n < 127 {
20			result += string(n)
21		}
22	}
23}