Compare commits
No commits in common. "e4eca321f6d1b883a8a2402753a0a47af1c51f4b" and "710f96e9e763873234577f72d792add32826b9ff" have entirely different histories.
e4eca321f6
...
710f96e9e7
10
main.go
10
main.go
@ -1,13 +1,12 @@
|
|||||||
// GoPass
|
// GoPass
|
||||||
// Author: Maximilian Patterson
|
// Author: Maximilian Patterson
|
||||||
// Version: 1.2.2
|
// Version: 1.2.1
|
||||||
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"
|
||||||
@ -61,12 +60,7 @@ 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
|
||||||
index, err := cryptorand.Int(cryptorand.Reader, big.NewInt(int64(len(allowedCharacters))))
|
pass[i] = allowedCharacters[mathrand.Intn(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