Exemplo n.º 1
0
func main() {
	max := 8
	fmt.Println("Testing performance of", max, "variants")
	fmt.Println("\nThis may take a minute...\n\n\n")
	for i := 0; i < max; i++ {
		fmt.Println("Test", i+1, "of", max, "begins")
		start := time.Now()
		algo, _ := statelessPassword.New([]byte("Example Full Name"), []byte("example password"), uint8(i))
		algo.Password("example.org", "1", statelessPassword.Printable32Templates)
		fmt.Println(time.Since(start), "\t", "Variant code:", i, "\n")
	}
}
Exemplo n.º 2
0
func main() {
	flag.Parse()

	s := bufio.NewScanner(os.Stdin)
	fullname := getFullname(s)
	bytMasterPw := getMasterpassword(s)

	params := make(chan param, 1)
	pwd := make(chan string, 1)

	go func() {
		algo, err := statelessPassword.New([]byte(fullname), bytMasterPw, 5)
		if err != nil {
			fmt.Println(err)
			os.Exit(1)
		}
		for {
			p := <-params
			pw, err := algo.Password(p.site, p.version, p.tlps)
			if err != nil {
				fmt.Println(err)
				os.Exit(1)
			}
			pwd <- pw
		}
	}()

	for {
		site, ok := getSite(s)
		if !ok {
			continue
		}

		version, ok := getVersion(s)
		if !ok {
			continue
		}

		tlps, ok := getTemplates(s)
		if !ok {
			continue
		}

		params <- param{site, version, tlps}
		returnPw(pwd)

		if *noTerminal {
			break
		}
	}
}