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 55223d0d35
Lint: Update linter config, fix linter error
Signed-off-by: Knut Ahlers <knut@ahlers.me>
2024-12-12 10:41:31 +01:00

16 lines
284 B
Go

package securepassword
import (
"crypto/rand"
"fmt"
"math/big"
)
func randIntn(maxN int) (int, error) {
cidx, err := rand.Int(rand.Reader, big.NewInt(int64(maxN)))
if err != nil {
return 0, fmt.Errorf("generating random number: %w", err)
}
return int(cidx.Int64()), nil
}