if sha256Coding(md5Coding(buf, m), s) == secret { mutex.Lock() // 获得互斥锁 if result == 0 { result = i fmt.Printf("Password: %d\n", i) cancel() // 发送取消信号 } mutex.Unlock() // 释放互斥锁 } lastTry = i }(i) select { case <-ctx.Done(): return default: } } wg.Wait() if result == 0 { fmt.Printf("Increased search to %d digits, no match found yet. Continuing...\n", len(strconv.Itoa(endPassword-1))) } else { return } } fmt.Println("No match found up to 13 digits. Please check your secret.") }
funcmd5Coding(v []byte, m hash.Hash)string { m.Write(v) return hex.EncodeToString(m.Sum(nil)) }
funcsha256Coding(v string, s hash.Hash)string { s.Write([]byte(v)) return hex.EncodeToString(s.Sum(nil)) }