1
0
Fork 0
mirror of https://github.com/Luzifer/password.git synced 2024-12-20 12:51:17 +00:00
password/lib/helpers.go
Knut Ahlers 83660a3cdf
Update dependencies, replace usage of fmt.Errorf
Signed-off-by: Knut Ahlers <knut@ahlers.me>
2022-06-27 19:45:12 +02:00

17 lines
298 B
Go

package securepassword
import (
"crypto/rand"
"math/big"
"github.com/pkg/errors"
)
func randIntn(max int) (int, error) {
cidx, err := rand.Int(rand.Reader, big.NewInt(int64(max)))
if err != nil {
return 0, errors.Wrap(err, "generating random number")
}
return int(cidx.Int64()), nil
}