mirror of
https://github.com/wneessen/apg-go.git
synced 2024-11-22 13:50:49 +01:00
Minor changes
This commit is contained in:
parent
808725501d
commit
19ed4da161
1 changed files with 3 additions and 3 deletions
6
apg.go
6
apg.go
|
@ -4,7 +4,6 @@ import (
|
||||||
"crypto/rand"
|
"crypto/rand"
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
|
||||||
"math/big"
|
"math/big"
|
||||||
"os"
|
"os"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
@ -119,7 +118,7 @@ func main() {
|
||||||
func getRandChar(charRange *string, pwLength int) string {
|
func getRandChar(charRange *string, pwLength int) string {
|
||||||
availCharsLength := len(*charRange)
|
availCharsLength := len(*charRange)
|
||||||
charSlice := []byte(*charRange)
|
charSlice := []byte(*charRange)
|
||||||
returnString := []byte{}
|
returnString := make([]byte, pwLength)
|
||||||
for i := 0; i < pwLength; i++ {
|
for i := 0; i < pwLength; i++ {
|
||||||
randNum := getRandNum(availCharsLength)
|
randNum := getRandNum(availCharsLength)
|
||||||
returnString = append(returnString, charSlice[randNum])
|
returnString = append(returnString, charSlice[randNum])
|
||||||
|
@ -131,7 +130,8 @@ func getRandNum(maxNum int) int {
|
||||||
maxNumBigInt := big.NewInt(int64(maxNum))
|
maxNumBigInt := big.NewInt(int64(maxNum))
|
||||||
randNum64, err := rand.Int(rand.Reader, maxNumBigInt)
|
randNum64, err := rand.Int(rand.Reader, maxNumBigInt)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("An error occured generating random number: %v", err)
|
fmt.Printf("An error occured while generating random number: %v", err)
|
||||||
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
randNum := int(randNum64.Int64())
|
randNum := int(randNum64.Int64())
|
||||||
return randNum
|
return randNum
|
||||||
|
|
Loading…
Reference in a new issue