Compare commits
12 Commits
3f1cbdc9a7
...
v1.1
Author | SHA1 | Date | |
---|---|---|---|
![]() |
8114d2a6c9 | ||
![]() |
7b36f39de6 | ||
![]() |
564da340d5 | ||
![]() |
9e3549f57d | ||
e72f27f80c | |||
![]() |
1bc20536b5 | ||
![]() |
03b6ac8375 | ||
![]() |
388d56b697 | ||
![]() |
0c3198536f | ||
![]() |
b1ddefb847 | ||
![]() |
bbfcf4d5f0 | ||
![]() |
4dd661572b |
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>
|
||||
|
BIN
bin/gopass-amd64-linux
Executable file
BIN
bin/gopass-amd64-linux
Executable file
Binary file not shown.
BIN
bin/gopass-amd64-osx
Executable file
BIN
bin/gopass-amd64-osx
Executable file
Binary file not shown.
BIN
bin/gopass-amd64-windows
Normal file
BIN
bin/gopass-amd64-windows
Normal file
Binary file not shown.
2
go.mod
2
go.mod
@@ -1,3 +1,3 @@
|
||||
module GoPass
|
||||
|
||||
go 1.18
|
||||
go 1.19
|
||||
|
19
main.go
19
main.go
@@ -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
|
||||
|
Reference in New Issue
Block a user