Ejemplo n.º 1
0
func main() {
	flag.StringVar(&pw, "pw", "", "Password to hash")
	flag.Parse()
	if pw == "" {
		pw = strings.Join(flag.Args(), " ")
	}
	var h = phpass.New(nil)
	hash, _ := h.Hash([]byte(pw))
	fmt.Println(string(hash))
}
Ejemplo n.º 2
0
func main() {
	flag.StringVar(&hash, "hash", "", "Hash to validate against")
	flag.StringVar(&pw, "pw", "", "Password validate")
	flag.Parse()
	if len(flag.Args()) > 1 {
		if pw == "" {
			pw = strings.Join(flag.Args()[1:], " ")
		}
		if hash == "" {
			hash = flag.Args()[0]
		}
	}
	var h = phpass.New(nil)
	if h.Check([]byte(pw), []byte(hash)) {
		fmt.Println("true")
	} else {
		fmt.Println("false")
		os.Exit(1)
	}
}