A tiny golang tool for generating a crypto-random password in a terminal.
go install github.com/hedhyw/go-psw/cmd/psw@latest
psw [LENGTH] [CHARS_PATTERN]
# Just generate a secure-random password:
psw
# Generate a password of length 10:
psw 10
# Generate only with given pattern (next example will print [a-zA-Z]):
psw 10 aA
# Special case (next example will print only [ёàは]):
psw 10 ёàは
package main
import (
"fmt"
"log"
"github.com/hedhyw/go-psw/pkg/v1/consts"
"github.com/hedhyw/go-psw/pkg/v1/generator"
)
func main() {
g := generator.NewCryptoRandGenerator()
chars, err := g.GeneratePassword(
consts.Digits+consts.LowerLetters, // Chars to use.
10, // Password length.
)
if err != nil {
log.Fatal(err)
}
fmt.Println(chars)
}
See License.