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.work
|
||||
|
||||
/.idea/
|
@ -1,5 +1,5 @@
|
||||
# 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:
|
||||
<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
|
||||
// Author: Maximilian Patterson
|
||||
// Version: 1.1
|
||||
package main
|
||||
|
||||
import (
|
||||
cryptorand "crypto/rand"
|
||||
"encoding/binary"
|
||||
"fmt"
|
||||
"math/rand"
|
||||
mathrand "math/rand"
|
||||
"os"
|
||||
"strconv"
|
||||
"time"
|
||||
)
|
||||
|
||||
var runes = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890`~!@#$%^&*()_+[]\\{}|;':,./<>?")
|
||||
@ -26,11 +28,16 @@ func main() {
|
||||
pass := make([]rune, size)
|
||||
|
||||
// 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)
|
||||
for i := range pass {
|
||||
pass[i] = runes[rand.Intn(len(runes))]
|
||||
pass[i] = runes[mathrand.Intn(len(runes))]
|
||||
}
|
||||
|
||||
// Print the pass :D
|
||||
|
Reference in New Issue
Block a user