commit 71242945fdd21594e49d06b0870cd8f76ae2006e Author: max Date: Tue Aug 2 17:37:06 2022 -0500 Initial commit, version 1.0 diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..27e10a1 --- /dev/null +++ b/go.mod @@ -0,0 +1,3 @@ +module GoPass + +go 1.18 diff --git a/main.go b/main.go new file mode 100644 index 0000000..c36b106 --- /dev/null +++ b/main.go @@ -0,0 +1,36 @@ +package GoPass + +import ( + "fmt" + "math/rand" + "os" + "strconv" + "time" +) + +var runes = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890`~!@#$%^&*()_+[]\\{}|;':,./<>?") + +func main() { + // Take OS arg (only accepts one arg) + arg := os.Args[1] + + // Convert String arg to int + size, err := strconv.Atoi(arg) + if err != nil { + panic(err) + } + + // Make empty array of runes with size of size + pass := make([]rune, size) + + // Seed rand with time + rand.Seed(time.Now().UTC().UnixNano()) + + // 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))] + } + + // Print the pass :D + fmt.Println(string(pass)) +}