50 Commits

Author SHA1 Message Date
max
fe11983dab Make version reflect build version 2025-03-10 14:07:37 -05:00
max
1e93add7bd Make version reflect build version 2025-03-10 14:05:22 -05:00
max
c328726ed0 Build with latest Go version 2025-03-10 14:04:19 -05:00
max
7e826b75d7 Fixed 1.3.3 build 2024-11-01 14:40:05 -05:00
max
72f4797428 Fix version displayed by -v 2024-11-01 14:39:24 -05:00
max
aad2144e7c Build updated binaries 2024-11-01 14:31:08 -05:00
max
a1c8d6e531 Bump version 2024-11-01 14:30:16 -05:00
max
0d5d7503ec Build with Go 1.23.2 2024-11-01 14:29:11 -05:00
max
ee1a0fedcc Build with Go 1.22 2024-02-14 13:39:33 -06:00
max
3fc3f35bb5 Bump version to 1.3.2 2024-02-14 13:32:56 -06:00
max
9a98788476 Update Go version to 1.22 2024-02-14 13:32:07 -06:00
43b8d3b618 Update binaries to 1.3.1 2023-02-14 16:33:07 -06:00
6d1e700d8b Update version 2023-02-14 16:12:15 -06:00
1b2fcd72b9 Use switch statements for argument matching, use a map for removing disallowedCharacters, and set up worker pool for concurrent "chunk" generation of the password 2023-02-14 16:12:02 -06:00
6c20c7bb8b Add go.sum 2023-02-14 15:27:38 -06:00
f5289baecd Update Go version to 1.20 2023-02-14 15:27:24 -06:00
max
bb4dda5d9f Add new release binaries for 1.3.0 2023-02-07 08:21:16 -06:00
max
14b7b1d181 Update README.md 2023-02-07 08:16:09 -06:00
max
83c7065d2a Full refactor, remove dead code, remove math/rand, add version arg, remove symbol arg, help arg, and improve remove disallowed character argument 2023-02-07 08:06:22 -06:00
max
3978c9ad47 Preemptively add building support (for version 1.3.0) for freebsd (386, amd64, and arm), plan9 (386, amd64, and arm), and Linux/Windows arm 2023-02-03 17:55:43 -06:00
e1ced3f76d Update binaries to the latest version 2023-01-30 00:06:15 -06:00
cdbca3b074 Add makefile 2023-01-30 00:05:53 -06:00
e4eca321f6 Update version 2023-01-29 23:37:46 -06:00
0eacc92a45 Formatting 2023-01-29 23:36:47 -06:00
e96fded8ff Cryptographically generate password characters 2023-01-29 23:30:21 -06:00
max
710f96e9e7 Update binaries to the latest version 2023-01-29 17:44:50 -06:00
max
4609be7a9d Update version 2023-01-29 17:12:49 -06:00
max
57b78dc62e Gracefully handle errors instead of panic 2023-01-29 16:16:44 -06:00
87fa1107d7 Update binaries to the latest version 2022-12-19 18:12:53 -06:00
max
3915761477 Update 'README.md'
Fixed formatting
2022-12-20 00:01:13 +00:00
5ba592db21 Update README.md to include install instructions and expanded usage instructions 2022-12-19 17:57:53 -06:00
b81783b470 New version update that supports disallowed characters, cleaned up comments 2022-12-19 17:41:54 -06:00
cebcbc2823 Merge remote-tracking branch 'origin/master' 2022-12-19 17:25:50 -06:00
b5b7c208f2 (Old binaries were broken) Rebuilt all binaries properly this time also included are the new error handling changes, and smaller overall binary sizes (built with -w and -s flags + UPX compression) 2022-12-19 17:25:17 -06:00
8aa2f61b3c (Old binaries were broken) Rebuilt all binaries properly this time also included are the new error handling changes, and smaller overall binary sizes (built with -w and -s flags + UTX compression) 2022-12-19 17:17:11 -06:00
f2a9cdd216 Added better error handling 2022-12-19 10:21:06 -06:00
c99539c0a9 Add 32 bit binaries for Linux and Windows, recompile Windows, Linux, and osx (Darwin) with new Go version (1.19.4) 2022-12-14 16:37:52 -06:00
33cf6cde39 Update README.md 2022-12-14 15:09:43 -06:00
8114d2a6c9 Remove .exe file extension, it false flags on Windows 10 antivirus 2022-10-21 10:05:31 -05:00
7b36f39de6 Update gitignore to allow for .exe and show Windows binary with updated file extension 2022-10-21 10:01:11 -05:00
564da340d5 Include .exe extension for Windows, this is required for the binary to be recognized 2022-10-21 09:58:04 -05:00
Max
9e3549f57d Merge remote-tracking branch 'origin/master' 2022-10-09 16:17:54 -05:00
max
e72f27f80c Update 'README.md' 2022-10-09 21:17:41 +00:00
Max
1bc20536b5 Update to V1.1 and compile with Go 1.19 2022-10-09 16:15:45 -05:00
Max
03b6ac8375 Update to securely seed math/rand V1.1 2022-10-09 15:57:01 -05:00
Max
388d56b697 Switch to the latest Go version 2022-10-09 15:28:28 -05:00
Max
0c3198536f Update gitignore 2022-10-09 15:28:04 -05:00
max
b1ddefb847 Fix osx binary name 2022-08-12 16:07:52 -05:00
max
bbfcf4d5f0 Release Version 1.0 binaries 2022-08-02 18:08:57 -05:00
max
4dd661572b Fixed package name 2022-08-02 18:07:28 -05:00
19 changed files with 235 additions and 23 deletions

1
.gitignore vendored
View File

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

View File

@ -1,9 +1,38 @@
# GoPass
An easy to use command-line password generator that creates secure passwords
# Usage:
<code>./gopass [number of characters]</code><br>
`./gopass [number of characters]`<br>
or <br>
`./gopass [number of characters] -r=[excluded characters] [-s to remove all symbols]`
<hr>
eg:
<code>./gopass 32</code><br>
output: <code>E$bGOiiPASS*,ISl{!MJ&<\[COOL0eVw</code>
eg: `./gopass 32` <br>
output: `E$bGOiiPASS*,ISl{!MJ&<\[COOL0eVw` <br>
eg: (with excluded characters): `./gopass 32 -r=$,!` <br>
output: `EYbGOiiPASS*2ISl{?MJ&<\[COOL0eVw` <- note the excluded characters are not present in the output <br>
eg: `./gopass 32 -s` <br>
output: `LEYbGOiiPASS2ISlMJCOOL0eRt3KPOVw` <- note the symbols are not present in the output <br>
eg: `./gopass 32 -r=$,! -s` the -r and -s flags can be combined <br>
# How to install/use for Windows:
1. Download Windows binary, it may be helpful to simply rename it to "gopass.exe" (make sure to add .exe, this won't
need to
be typed to execute the file from the CLI, but it is required for Windows to recognize the binary) to keep
commands shorter.
2. Move the file to your `C:\Users\[Username]` directory
3. Opening the console *without* Administrator privileges will put you in the directory mentioned above by default
4. Now type `gopass [number of characters]` (Ex. `gopass 64`) to generate a new password!
# How to install/use for Linux:
1. Download Linux binary, it may be helpful to simply rename it to "gopass" to keep commands shorter.
2. Move the file to your home directory.
3. `chmod +x gopass` if necessary
3. Opening your terminal should put you in your home directory by default, if not, just type `cd` to get sent back to
home.
4. Now type `./gopass [number of characters]` (Ex. `./gopass 64`) to generate a new password!

BIN
bin/gopass-darwin-amd64-1.3.4 Executable file

Binary file not shown.

BIN
bin/gopass-freebsd-386-1.3.4 Executable file

Binary file not shown.

BIN
bin/gopass-freebsd-amd64-1.3.4 Executable file

Binary file not shown.

BIN
bin/gopass-freebsd-arm-1.3.4 Executable file

Binary file not shown.

BIN
bin/gopass-linux-386-1.3.4 Executable file

Binary file not shown.

BIN
bin/gopass-linux-amd64-1.3.4 Executable file

Binary file not shown.

BIN
bin/gopass-linux-arm-1.3.4 Executable file

Binary file not shown.

BIN
bin/gopass-plan9-386-1.3.4 Executable file

Binary file not shown.

BIN
bin/gopass-plan9-amd64-1.3.4 Executable file

Binary file not shown.

BIN
bin/gopass-plan9-arm-1.3.4 Executable file

Binary file not shown.

BIN
bin/gopass-windows-386-1.3.4 Executable file

Binary file not shown.

BIN
bin/gopass-windows-amd64-1.3.4 Executable file

Binary file not shown.

BIN
bin/gopass-windows-arm-1.3.4 Executable file

Binary file not shown.

2
go.mod
View File

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

0
go.sum Normal file
View File

131
main.go
View File

@ -1,36 +1,131 @@
package GoPass
// GoPass
// Author: Maximilian Patterson
package main
import (
"crypto/rand"
"fmt"
"math/rand"
"math/big"
"os"
"runtime"
"strconv"
"time"
"strings"
)
var runes = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890`~!@#$%^&*()_+[]\\{}|;':,./<>?")
var allowedCharacters = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890`~!@#$%^&*()_+[]\\{}|;':,./<>?")
func main() {
// Take OS arg (only accepts one arg)
arg := os.Args[1]
const (
Version = "1.3.4"
symbols = "`~!@#$%^&*()_+[]\\{}|;':,./<>?"
chunkSize = 16 // The size of each chunk of the password to be generated by the worker goroutines
)
// Convert String arg to int
size, err := strconv.Atoi(arg)
if err != nil {
panic(err)
func matchArguments(args []string) string {
// If there are no arguments
if len(args) == 0 {
return "No password length specified! (ex: gopass 16)"
}
// First argument is special, must be an integer, -v, or -h
var size = 0 // Password length
switch args[0] {
case "-v":
return "GoPass version " + Version
case "-h":
return "GoPass - A simple password generator written in Go\n" +
"Usage: gopass [length] [disallowed characters] [optional remove symbols -s]\n" +
" Example: gopass 16\n" +
" Example: gopass 16 -r=abc123!@#\n" +
" Example: gopass 16 -s\n" +
"\nFor help (this output): gopass -h\n" +
"For version: gopass -v\n"
default:
err := error(nil)
size, err = strconv.Atoi(args[0])
if err != nil {
return "Invalid first argument (\"" + args[0] + "\") supplied! (Type gopass -h for help)"
}
}
for i := 1; i < len(args); i++ {
v := args[i]
switch {
case v == "-s":
removeDisallowed([]rune(symbols))
case strings.HasPrefix(v, "-r="):
// Remove all characters after the = until next whitespace
removeDisallowed([]rune(v[2:]))
default:
return "Invalid argument (\"" + v + "\") supplied! (Type gopass -h for help)"
}
}
if size <= 0 {
return "No/invalid password length specified! (ex: gopass 16)"
} else {
return generatePassword(size)
}
}
// Remove all disallowed characters from the allowedCharacters slice
func removeDisallowed(disallowed []rune) {
disallowedMap := make(map[rune]bool, len(disallowed))
for _, r := range disallowed {
disallowedMap[r] = true
}
i := 0
for _, v := range allowedCharacters {
if !disallowedMap[v] {
allowedCharacters[i] = v
i++
}
}
allowedCharacters = allowedCharacters[:i]
}
func generatePassword(size int) string {
// Make empty array of runes with size of size
pass := make([]rune, size)
// Seed rand with time
rand.Seed(time.Now().UTC().UnixNano())
// Create a channel to receive chunks of the password
passChan := make(chan []rune)
// 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))]
// Determine the number of worker goroutines to use
numWorkers := runtime.NumCPU()
// Launch the worker goroutines
for i := 0; i < numWorkers; i++ {
go func() {
allowedLen := len(allowedCharacters)
for {
// Generate a chunk of the password
chunk := make([]rune, chunkSize)
for i := range chunk {
index, err := rand.Int(rand.Reader, big.NewInt(int64(allowedLen)))
if err != nil {
println("Error securely generating random character chunk!")
return
}
chunk[i] = allowedCharacters[index.Int64()]
}
// Send the chunk of the password to the main goroutine
passChan <- chunk
}
}()
}
// Print the pass :D
fmt.Println(string(pass))
// Collect the chunks of the password from the channel
for i := 0; i < size; i += chunkSize {
chunk := <-passChan
copy(pass[i:], chunk)
}
return string(pass)
}
func main() {
// Process arguments
fmt.Println(matchArguments(os.Args[1:]))
}

87
makefile Normal file
View File

@ -0,0 +1,87 @@
# The current version number of the program
VERSION := 1.3.4
# List of OS and architecture combinations to build
BUILD_OS_ARCH := \
darwin/amd64 \
freebsd/386 \
freebsd/amd64 \
freebsd/arm \
linux/386 \
linux/amd64 \
linux/arm \
plan9/386 \
plan9/amd64 \
plan9/arm \
windows/386 \
windows/amd64 \
windows/arm
# 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
freebsd/386:
GOOS=freebsd \
GOARCH=386 \
go build -ldflags="-s -w" -o "gopass-freebsd-386-$(VERSION)" main.go
freebsd/amd64:
GOOS=freebsd \
GOARCH=amd64 \
go build -ldflags="-s -w" -o "gopass-freebsd-amd64-$(VERSION)" main.go
freebsd/arm:
GOOS=freebsd \
GOARCH=arm \
go build -ldflags="-s -w" -o "gopass-freebsd-arm-$(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
linux/arm:
GOOS=linux \
GOARCH=arm \
go build -ldflags="-s -w" -o "gopass-linux-arm-$(VERSION)" main.go
plan9/386:
GOOS=plan9 \
GOARCH=386 \
go build -ldflags="-s -w" -o "gopass-plan9-386-$(VERSION)" main.go
plan9/amd64:
GOOS=plan9 \
GOARCH=amd64 \
go build -ldflags="-s -w" -o "gopass-plan9-amd64-$(VERSION)" main.go
plan9/arm:
GOOS=plan9 \
GOARCH=arm \
go build -ldflags="-s -w" -o "gopass-plan9-arm-$(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
windows/arm:
GOOS=windows \
GOARCH=arm \
go build -ldflags="-s -w" -o "gopass-windows-arm-$(VERSION)" main.go