go get github.com/sethvargo/go-password
git clone
this repogo build path/to/genpass.go
- move genpass to your PATH
Created
April 17, 2018 02:36
-
-
Save peccu/ebc0cecfc8dd68bdc4d53633897e3dde to your computer and use it in GitHub Desktop.
generate password command using sethvargo/go-password
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
// "regexp" | |
"fmt" | |
"github.com/sethvargo/go-password/password" | |
) | |
func main() { | |
// Generate a password that is 64 characters long with 10 digits, 10 symbols, | |
// allowing upper and lower case letters, disallowing repeat characters. | |
orig, err := password.Generate(8, 2, 2, false, false) | |
if err != nil { | |
fmt.Println(err) | |
} | |
fmt.Print(orig) | |
// // GitBucket can't use some symbols. | |
// orig, err := password.Generate(64, 10, 20, false, false) | |
// // Remove some symbols from generated string | |
// r := regexp.MustCompile("[^a-zA-Z0-9\\-_.]") | |
// res := r.ReplaceAllString(orig, "")[:8] | |
// fmt.Print(res) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment