diff --git a/README.md b/README.md index d8fe316..347e939 100644 --- a/README.md +++ b/README.md @@ -165,8 +165,8 @@ PS C:\Users\somebody\Downloads> .\passwordgen-v1.3.0-windows-amd64.exe -passphra # Building releases for multiple platforms ```shell -GOOS=darwin GOARCH=arm64 go build -o Release-Binaries/v1.3.x/passwordgen-v1.3.0-darwin-arm64 -GOOS=darwin GOARCH=amd64 go build -o Release-Binaries/v1.3.x/passwordgen-v1.3.0-darwin-amd64 -GOOS=windows GOARCH=amd64 go build -o Release-Binaries/v1.3.x/passwordgen-v1.3.0-windows-amd64.exe -GOOS=linux GOARCH=amd64 go build -o Release-Binaries/v1.3.x/passwordgen-v1.3.0-linux-amd64 +GOOS=darwin GOARCH=arm64 go build -o Release-Binaries/v1.4.x/passwordgen-v1.4.0-darwin-arm64 +GOOS=darwin GOARCH=amd64 go build -o Release-Binaries/v1.4.x/passwordgen-v1.4.0-darwin-amd64 +GOOS=windows GOARCH=amd64 go build -o Release-Binaries/v1.4.x/passwordgen-v1.4.0-windows-amd64.exe +GOOS=linux GOARCH=amd64 go build -o Release-Binaries/v1.4.x/passwordgen-v1.4.0-linux-amd64 ``` \ No newline at end of file diff --git a/Release-Binaries/v1.3.x/passwordgen-v1.3.0-windows-amd64.exe b/Release-Binaries/v1.3.x/passwordgen-v1.3.0-windows-amd64.exe index a152cb5..139ff77 100755 Binary files a/Release-Binaries/v1.3.x/passwordgen-v1.3.0-windows-amd64.exe and b/Release-Binaries/v1.3.x/passwordgen-v1.3.0-windows-amd64.exe differ diff --git a/Release-Binaries/v1.4.x/passwordgen-v1.4.0-darwin-amd64 b/Release-Binaries/v1.4.x/passwordgen-v1.4.0-darwin-amd64 new file mode 100755 index 0000000..198525e Binary files /dev/null and b/Release-Binaries/v1.4.x/passwordgen-v1.4.0-darwin-amd64 differ diff --git a/Release-Binaries/v1.4.x/passwordgen-v1.4.0-darwin-arm64 b/Release-Binaries/v1.4.x/passwordgen-v1.4.0-darwin-arm64 new file mode 100755 index 0000000..74d2dd4 Binary files /dev/null and b/Release-Binaries/v1.4.x/passwordgen-v1.4.0-darwin-arm64 differ diff --git a/Release-Binaries/v1.4.x/passwordgen-v1.4.0-linux-amd64 b/Release-Binaries/v1.4.x/passwordgen-v1.4.0-linux-amd64 new file mode 100755 index 0000000..0f5d9e6 Binary files /dev/null and b/Release-Binaries/v1.4.x/passwordgen-v1.4.0-linux-amd64 differ diff --git a/Release-Binaries/v1.4.x/passwordgen-v1.4.0-windows-amd64.exe b/Release-Binaries/v1.4.x/passwordgen-v1.4.0-windows-amd64.exe new file mode 100755 index 0000000..1ee9379 Binary files /dev/null and b/Release-Binaries/v1.4.x/passwordgen-v1.4.0-windows-amd64.exe differ diff --git a/passwordgen b/passwordgen index b242707..89d430a 100755 Binary files a/passwordgen and b/passwordgen differ diff --git a/passwordgen.go b/passwordgen.go index 2049bbf..1fb6db8 100644 --- a/passwordgen.go +++ b/passwordgen.go @@ -95,14 +95,7 @@ func main() { if OS == "darwin" || OS == "linux" || OS == "unix" { // Fill the screen with passwords - arrayPasswords = printPasswordTableUnix( - rows, - requestedPasswordLength, - arrayPasswords, - *randomPasswords, - *wordChains, - *mixedPasswords, - *passPhrases) + arrayPasswords = printPasswordTableUnix(arrayPasswords, *randomPasswords, *wordChains, *mixedPasswords, *passPhrases) } else if OS == "windows" { diff --git a/printUtils.go b/printUtils.go index 7d7d372..24ec355 100644 --- a/printUtils.go +++ b/printUtils.go @@ -162,104 +162,6 @@ func printPasswordTableWindows( return arrayPasswords } -// colorizeCharactersWindows() prints and does not return anything -func colorizeCharactersWindows(requestedPasswordLength int, password string) { - - var coloredCharsString string - - // Trim the password down to the requestedPasswordLength - //password = trimPassword(password, requestedPasswordLength) - - // Check each character's ascii value and colorize according to category - for i := 0; i < requestedPasswordLength; i++ { - - // Convert the character back to ascii value for the color assignment - character := int32(password[i]) - - // TODO: Make uppercase and lowercase Hi colors and others not Hi. - - if character >= 65 && character <= 90 { - - // Assign a color to uppercase characters - color.NoColor = false - uppercaseColorPrint := color.New(color.FgCyan).PrintfFunc() - uppercaseColorPrint(string(character)) - color.NoColor = true - - } else if character >= 97 && character <= 122 { - - // Assign a color to lowercase characters - color.NoColor = false - lowercaseColorPrint := color.New(color.FgGreen).PrintfFunc() - lowercaseColorPrint(string(character)) - color.NoColor = true - - } else if character >= 48 && character <= 57 { - - // Assign a color to number characters - color.NoColor = false - numberColorPrint := color.New(color.FgHiCyan).PrintfFunc() - numberColorPrint(string(character)) - color.NoColor = true - - } else if character >= 33 && character <= 47 { - - if character == 37 { - - // Double the % sign or printf thinks it is a formatting symbol - color.NoColor = false - specialCharColorPrint := color.New(color.FgHiGreen).PrintfFunc() - specialCharColorPrint("%%") - color.NoColor = true - - } else { - - // Assign a color to special characters, first range - color.NoColor = false - specialCharColorPrint := color.New(color.FgHiGreen).PrintfFunc() - specialCharColorPrint(string(character)) - color.NoColor = true - - } - } else if character >= 58 && character <= 64 { - - // Assign a color to special characters, second range - color.NoColor = false - specialCharColorPrint := color.New(color.FgHiGreen).PrintfFunc() - specialCharColorPrint(string(character)) - color.NoColor = true - - } else if character >= 91 && character <= 96 { - - // Assign a color to special characters, third range - color.NoColor = false - specialCharColorPrint := color.New(color.FgHiGreen).PrintfFunc() - specialCharColorPrint(string(character)) - color.NoColor = true - - } else if character >= 123 && character <= 126 { - - // Assign a color to special characters, fourth range - color.NoColor = false - specialCharColorPrint := color.New(color.FgHiGreen).PrintfFunc() - specialCharColorPrint(string(character)) - color.NoColor = true - - } else { - - // Assign a color to any character not represented above - color.NoColor = false - specialCharColorPrint := color.New(color.FgHiYellow).PrintfFunc() - specialCharColorPrint(string(character)) - color.NoColor = true - - } - color.NoColor = true - } - - fmt.Print(coloredCharsString) -} - // printPasswordTableUnix prints a table of randomized passwords with index numbers to the terminal screen. // // The function takes in the number of rows to print, the requested length of each password, @@ -273,107 +175,8 @@ func colorizeCharactersWindows(requestedPasswordLength int, password string) { // - requestedPasswordLength: an int specifying the length of each password to generate // - arrayPasswords: a slice of strings representing the passwords to be populated // Returns: nothing -func printPasswordTableUnix( - rows int, - requestedPasswordLength int, - arrayPasswords []string, - randomPasswords bool, - wordChains bool, - mixedPasswords bool, - passPhrases bool) []string { - - grey := color.New(color.FgCyan, color.Faint).SprintfFunc() - underline := grey("─") - - if !passPhrases && !wordChains && !mixedPasswords && !randomPasswords { - - fmt.Printf( - "%s%s%s\n", - grey("+────+"), - strings.Repeat(underline, requestedPasswordLength+2), - grey("+"), - ) - } - // Loop to print rows of index numbers and passwords to the terminal screen - for rowNumber := 0; rowNumber < ((rows / 2) - 1); rowNumber++ { - - if !passPhrases && !wordChains && !mixedPasswords && !randomPasswords { - - red := color.New(color.FgRed).SprintFunc() - rowNumberString := fmt.Sprintf("%02d", rowNumber) - - // Print an index number for each printed password - color.NoColor = false - fmt.Printf("%s %s %s ", grey("│"), red(rowNumberString), grey("│")) - } - - if randomPasswords { - - break - - //// Fetch a new randomized password string of the specified length - //password := randStringPassword(requestedPasswordLength) - // - //arrayPasswords[rowNumber] = password - // - //// Colorize and print the password - //colorizeCharactersUnix(requestedPasswordLength, password, true) - - } else if wordChains { - - break - - } else if mixedPasswords { - - password := createMixedPassword(mixedPasswords, randomPasswords, rows) - - arrayPasswords[rowNumber] = password - - break - // Colorize and print the password - //colorizeCharactersUnix(requestedPasswordLength, password, true) - - } else if passPhrases { +func printPasswordTableUnix(arrayPasswords []string, randomPasswords bool, wordChains bool, mixedPasswords bool, passPhrases bool) []string { - password := createPassphrase() - - arrayPasswords[rowNumber] = password - - break - } - - // Vertical line after the password - fmt.Printf(" %s", grey("│")) - - // Newline at end of row - fmt.Printf("\n") - - //fmt.Printf("%s of %s %s\n", rowNumber, rows, len(arrayPasswords)) - - // If it's the final line we're printing - if rowNumber == (len(arrayPasswords) - 9) { - - // └ - fmt.Print(grey("+")) - } else if rowNumber >= 0 { - - // Beginning of row line, middle of table ├ - fmt.Print(grey("+")) - } - - // Line under password index number, then cross line character ┼ - fmt.Printf("%s%s", strings.Repeat(underline, 4), grey("+")) - - // Line between rows - fmt.Printf("%s", strings.Repeat(underline, requestedPasswordLength+2)) - - // End of row line ┤ - fmt.Printf("%s", grey("+")) - - // Newline at end of row line - fmt.Printf("\n") - - } if passPhrases { arrayPasswords = printPassphraseTable() @@ -395,7 +198,7 @@ func printPasswordTableUnix( return arrayPasswords } -func colorizeCharactersUnix(requestedPasswordLength int, password string, print bool) string { +func colorizeCharactersUnix(password string, print bool) string { var coloredCharsString string @@ -497,7 +300,7 @@ func printPassphraseTable() []string { // Colorize the passphrase that we're saving to the array // The following works on all platforms but no color renders on Windows - passphrase = colorizeCharactersUnix(len(passphrase), passphrase, false) + passphrase = colorizeCharactersUnix(passphrase, false) // Append the passphrase to the array arrayOfPassphrases[i] = passphrase @@ -557,7 +360,7 @@ func printWordChainsTable() []string { // Colorize the word chain that we're saving to the array // The following works on all platforms but no color renders on Windows - wordChainColorized := colorizeCharactersUnix(len(wordChainNoColor), wordChainNoColor, false) + wordChainColorized := colorizeCharactersUnix(wordChainNoColor, false) // Append the word chain to the array to be used by the clipboard if in interactive mode arrayOfWordChains[i] = wordChainNoColor @@ -601,7 +404,7 @@ func printMixedPasswordsTable(mixedPasswords bool, randomPasswords bool) []strin // Colorize the mixed password that we're saving to the array // The following works on all platforms but no color renders on Windows - mixedPasswordColorized := colorizeCharactersUnix(len(mixedPasswordNoColor), mixedPasswordNoColor, false) + mixedPasswordColorized := colorizeCharactersUnix(mixedPasswordNoColor, false) // Append the mixed password to the array to be used by the clipboard if in interactive mode arrayOfMixedPasswords[i] = mixedPasswordNoColor @@ -645,7 +448,7 @@ func printRandomPasswordsTable() []string { // Colorize the random password that we're saving to the array // The following works on all platforms but no color renders on Windows - randomPasswordColorized := colorizeCharactersUnix(len(randomPasswordNoColor), randomPasswordNoColor, false) + randomPasswordColorized := colorizeCharactersUnix(randomPasswordNoColor, false) // Append the random password to the array to be used by the clipboard if in interactive mode arrayOfRandomPasswords[i] = randomPasswordNoColor