12 Commits

7 changed files with 17 additions and 7 deletions

1
.gitignore vendored
View File

@ -21,3 +21,4 @@
# Go workspace file
go.work
/.idea/

View File

@ -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>

BIN
bin/gopass-amd64-linux Executable file

Binary file not shown.

BIN
bin/gopass-amd64-osx Executable file

Binary file not shown.

BIN
bin/gopass-amd64-windows Normal file

Binary file not shown.

2
go.mod
View File

@ -1,3 +1,3 @@
module GoPass
go 1.18
go 1.19

19
main.go
View File

@ -1,11 +1,15 @@
package GoPass
// 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`~!@#$%^&*()_+[]\\{}|;':,./<>?")
@ -24,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