Compare commits
8 Commits
Author | SHA1 | Date | |
---|---|---|---|
e1ced3f76d | |||
cdbca3b074 | |||
e4eca321f6 | |||
0eacc92a45 | |||
e96fded8ff | |||
710f96e9e7 | |||
4609be7a9d | |||
57b78dc62e |
BIN
bin/gopass-darwin-amd64-1.2.2
Normal file
BIN
bin/gopass-darwin-amd64-1.2.2
Normal file
Binary file not shown.
Binary file not shown.
BIN
bin/gopass-linux-386-1.2.2
Normal file
BIN
bin/gopass-linux-386-1.2.2
Normal file
Binary file not shown.
Binary file not shown.
BIN
bin/gopass-linux-amd64-1.2.2
Normal file
BIN
bin/gopass-linux-amd64-1.2.2
Normal file
Binary file not shown.
Binary file not shown.
BIN
bin/gopass-windows-386-1.2.2
Normal file
BIN
bin/gopass-windows-386-1.2.2
Normal file
Binary file not shown.
Binary file not shown.
BIN
bin/gopass-windows-amd64-1.2.2
Normal file
BIN
bin/gopass-windows-amd64-1.2.2
Normal file
Binary file not shown.
Binary file not shown.
19
main.go
19
main.go
@ -1,12 +1,13 @@
|
|||||||
// GoPass
|
// GoPass
|
||||||
// Author: Maximilian Patterson
|
// Author: Maximilian Patterson
|
||||||
// Version: 1.2.0
|
// Version: 1.2.2
|
||||||
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"
|
||||||
@ -18,13 +19,15 @@ func main() {
|
|||||||
// Take in all OS arg
|
// Take in all OS arg
|
||||||
args := os.Args[1:]
|
args := os.Args[1:]
|
||||||
if len(args) < 1 {
|
if len(args) < 1 {
|
||||||
panic("No password length specified! (ex: ./gopass 16)")
|
println("No password length specified! (ex: ./gopass 16)")
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convert String arg to int
|
// Convert String arg to int
|
||||||
size, err := strconv.Atoi(args[0])
|
size, err := strconv.Atoi(args[0])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic("First argument supplied must be an integer! (ex: 16)")
|
println("First argument supplied must be an integer! (ex: 16)")
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Grab second argument (if it exists) and use it as a disallowed character(s)
|
// Grab second argument (if it exists) and use it as a disallowed character(s)
|
||||||
@ -50,14 +53,20 @@ func main() {
|
|||||||
var b [8]byte
|
var b [8]byte
|
||||||
_, err = cryptorand.Read(b[:])
|
_, err = cryptorand.Read(b[:])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic("Error securely seeding crypto/rand!")
|
println("Error securely seeding crypto/rand!")
|
||||||
|
return
|
||||||
}
|
}
|
||||||
mathrand.Seed(int64(binary.LittleEndian.Uint64(b[:])))
|
mathrand.Seed(int64(binary.LittleEndian.Uint64(b[:])))
|
||||||
|
|
||||||
// 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
|
||||||
pass[i] = allowedCharacters[mathrand.Intn(len(allowedCharacters))]
|
index, err := cryptorand.Int(cryptorand.Reader, big.NewInt(int64(len(allowedCharacters))))
|
||||||
|
if err != nil {
|
||||||
|
println("Error securely generating random character!")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
pass[i] = allowedCharacters[index.Int64()]
|
||||||
}
|
}
|
||||||
|
|
||||||
// Print the password
|
// Print the password
|
||||||
|
39
makefile
Normal file
39
makefile
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
# The current version number of the program
|
||||||
|
VERSION := 1.2.2
|
||||||
|
|
||||||
|
# List of OS and architecture combinations to build
|
||||||
|
BUILD_OS_ARCH := \
|
||||||
|
darwin/amd64 \
|
||||||
|
linux/386 \
|
||||||
|
linux/amd64 \
|
||||||
|
windows/386 \
|
||||||
|
windows/amd64
|
||||||
|
|
||||||
|
# Build all targets
|
||||||
|
all: $(BUILD_OS_ARCH)
|
||||||
|
|
||||||
|
# Build targets in the form of `OS/ARCH`
|
||||||
|
darwin/amd64:
|
||||||
|
GOOS=darwin \
|
||||||
|
GOARCH=amd64 \
|
||||||
|
go build -ldflags="-s -w" -o "gopass-darwin-amd64-$(VERSION)" main.go
|
||||||
|
|
||||||
|
linux/386:
|
||||||
|
GOOS=linux \
|
||||||
|
GOARCH=386 \
|
||||||
|
go build -ldflags="-s -w" -o "gopass-linux-386-$(VERSION)" main.go
|
||||||
|
|
||||||
|
linux/amd64:
|
||||||
|
GOOS=linux \
|
||||||
|
GOARCH=amd64 \
|
||||||
|
go build -ldflags="-s -w" -o "gopass-linux-amd64-$(VERSION)" main.go
|
||||||
|
|
||||||
|
windows/386:
|
||||||
|
GOOS=windows \
|
||||||
|
GOARCH=386 \
|
||||||
|
go build -ldflags="-s -w" -o "gopass-windows-386-$(VERSION)" main.go
|
||||||
|
|
||||||
|
windows/amd64:
|
||||||
|
GOOS=windows \
|
||||||
|
GOARCH=amd64 \
|
||||||
|
go build -ldflags="-s -w" -o "gopass-windows-amd64-$(VERSION)" main.go
|
Reference in New Issue
Block a user