Compare commits
9 Commits
b1ddefb847
...
v1.1
Author | SHA1 | Date | |
---|---|---|---|
8114d2a6c9 | |||
7b36f39de6 | |||
564da340d5 | |||
9e3549f57d | |||
e72f27f80c | |||
1bc20536b5 | |||
03b6ac8375 | |||
388d56b697 | |||
0c3198536f |
1
.gitignore
vendored
1
.gitignore
vendored
@ -21,3 +21,4 @@
|
|||||||
# Go workspace file
|
# Go workspace file
|
||||||
go.work
|
go.work
|
||||||
|
|
||||||
|
/.idea/
|
@ -1,5 +1,5 @@
|
|||||||
# GoPass
|
# GoPass
|
||||||
An easy to use command-line password generator that creates secure passwords
|
An easy to use command-line password generator that creates secure passwords (Version 1.1 adds proper cryptographic seeding of math/rand)
|
||||||
|
|
||||||
# Usage:
|
# Usage:
|
||||||
<code>./gopass [number of characters]</code><br>
|
<code>./gopass [number of characters]</code><br>
|
||||||
|
Binary file not shown.
Binary file not shown.
BIN
bin/gopass-amd64-windows
Executable file → Normal file
BIN
bin/gopass-amd64-windows
Executable file → Normal file
Binary file not shown.
15
main.go
15
main.go
@ -1,13 +1,15 @@
|
|||||||
// GoPass
|
// GoPass
|
||||||
// Author: Maximilian Patterson
|
// Author: Maximilian Patterson
|
||||||
|
// Version: 1.1
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
cryptorand "crypto/rand"
|
||||||
|
"encoding/binary"
|
||||||
"fmt"
|
"fmt"
|
||||||
"math/rand"
|
mathrand "math/rand"
|
||||||
"os"
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var runes = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890`~!@#$%^&*()_+[]\\{}|;':,./<>?")
|
var runes = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890`~!@#$%^&*()_+[]\\{}|;':,./<>?")
|
||||||
@ -26,11 +28,16 @@ func main() {
|
|||||||
pass := make([]rune, size)
|
pass := make([]rune, size)
|
||||||
|
|
||||||
// Seed rand with time
|
// Seed rand with time
|
||||||
rand.Seed(time.Now().UTC().UnixNano())
|
var b [8]byte
|
||||||
|
_, err = cryptorand.Read(b[:])
|
||||||
|
if err != nil {
|
||||||
|
panic("Error securely seeding rand!")
|
||||||
|
}
|
||||||
|
mathrand.Seed(int64(binary.LittleEndian.Uint64(b[:])))
|
||||||
|
|
||||||
// Assign every slot of pass to a random rune (generate rand int of length runes to select)
|
// Assign every slot of pass to a random rune (generate rand int of length runes to select)
|
||||||
for i := range pass {
|
for i := range pass {
|
||||||
pass[i] = runes[rand.Intn(len(runes))]
|
pass[i] = runes[mathrand.Intn(len(runes))]
|
||||||
}
|
}
|
||||||
|
|
||||||
// Print the pass :D
|
// Print the pass :D
|
||||||
|
Reference in New Issue
Block a user