Пример #1
0
func promtPwd(text string, allowEmpty bool) (pwd string) {
	for {
		fmt.Print(text + ": ")
		pwd = string(gopass.GetPasswd())
		fmt.Print("Repeat: ")
		pwd2 := string(gopass.GetPasswd())
		if pwd != pwd2 {
			fmt.Println("Passwords do not match!")
			continue
		}
		if pwd == "" && !allowEmpty {
			fmt.Println("Empty password is not allowed.")
			continue
		}
		return
	}
}
Пример #2
0
func openStorage() (pss.Storage, string, bool) {
	fmt.Print("Master-password: "******"Wrong password")
		return nil, "", false
	} else if os.IsNotExist(err) {
		fmt.Println("Error: storage file does not exist.")
		fmt.Printf("Try calling `%v init` for setup.\n", os.Args[0])
		return nil, "", false
	} else if err != nil {
		fmt.Println("Error opening storage:")
		fmt.Println(err)
		return nil, "", false
	}

	return stg, pwd, true
}