package main
|
|
|
|
import (
|
|
"crypto/rand"
|
|
"math/big"
|
|
)
|
|
|
|
func generateChallenge(length int) (string, error) {
|
|
result := ""
|
|
for {
|
|
if len(result) >= length {
|
|
return result, nil
|
|
}
|
|
num, err := rand.Int(rand.Reader, big.NewInt(int64(127)))
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
n := num.Int64()
|
|
if n > 32 && n < 127 {
|
|
result += string(n)
|
|
}
|
|
}
|
|
}
|