Compare commits
3 Commits
710f96e9e7
...
e4eca321f6
Author | SHA1 | Date | |
---|---|---|---|
![]() |
e4eca321f6 | ||
![]() |
0eacc92a45 | ||
![]() |
e96fded8ff |
10
main.go
10
main.go
@ -1,12 +1,13 @@
|
|||||||
// GoPass
|
// GoPass
|
||||||
// Author: Maximilian Patterson
|
// Author: Maximilian Patterson
|
||||||
// Version: 1.2.1
|
// Version: 1.2.2
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
cryptorand "crypto/rand"
|
cryptorand "crypto/rand"
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"math/big"
|
||||||
mathrand "math/rand"
|
mathrand "math/rand"
|
||||||
"os"
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
@ -60,7 +61,12 @@ func main() {
|
|||||||
// Assign every slot of pass to a random allowedCharacter
|
// Assign every slot of pass to a random allowedCharacter
|
||||||
for i := range pass {
|
for i := range pass {
|
||||||
// Generate a random int greater than 0 and not to exceed the length of allowedCharacters
|
// Generate a random int greater than 0 and not to exceed the length of allowedCharacters
|
||||||
pass[i] = allowedCharacters[mathrand.Intn(len(allowedCharacters))]
|
index, err := cryptorand.Int(cryptorand.Reader, big.NewInt(int64(len(allowedCharacters))))
|
||||||
|
if err != nil {
|
||||||
|
println("Error securely generating random character!")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
pass[i] = allowedCharacters[index.Int64()]
|
||||||
}
|
}
|
||||||
|
|
||||||
// Print the password
|
// Print the password
|
||||||
|
Loading…
x
Reference in New Issue
Block a user