public Server(byte[] desiredHash) { this.desiredHash = desiredHash; for (int len = 0; len <= MaxStringLength - PerClientLength; len++) { char[] prefix = Transmutations.First(len); do { prefixes.Add(new string(prefix), null); } while (Transmutations.Next(prefix)); } }
private void CheckStrings(int stringsLength) { char[] suffix = Transmutations.First(stringsLength); do { string str = prefix + new string(suffix); byte[] bytes = Encoding.UTF8.GetBytes(str); byte[] hash = algorithm.ComputeHash(bytes); if (IsRightHash(hash)) { result = str; IsFinished = true; Console.WriteLine($"Found right string! Result: {result}"); return; } } while (Transmutations.Next(suffix)); }