Пример #1
0
//All requests made to the HTTP server are processed by this function
func httpRequestHandler(w http.ResponseWriter, r *http.Request) {

	err := r.ParseForm()
	if err != nil {
		fmt.Fprintf(w, "%s", err.Error())
	}

	//Prints webpage
	fmt.Fprintf(w, "<html><form action=\"\" method=\"post\"><input type=\"text\" name=\"hash\"><input type=\"submit\"></form></html>")

	//Retrive value from form of hash
	strHash := r.Form.Get("hash")

	//If hash exist
	if len(strHash) == 0 {
		return
	}

	worder, err := wordlist.New(os.Getenv("GOPATH") + "/src/github.com/karlek/gohash/a.txt")
	if err != nil {
		fmt.Println("New: ", err)
	}

	hash, err := str2hash.New(strHash)
	if err != nil {
		fmt.Println(err)
	}

	c := make(chan string)

	go worder.Check(hash, c)
	fmt.Println(<-c)
}
Пример #2
0
func main() {
	for _, s := range flag.Args() {
		hash, err := str2hash.New(s)
		if err != nil {
			log.Fatalln("str2hash.New:", err)
		}
		find(hash)
	}
}