static string str = "abcdefghijklmnoparstuvwxyzABCDEFGHIJKLMNOPaRSTUVWXYZ0123456789"; static void Main(string[] args) { string ac = Console.ReadLine(); for (int a = 0; (a < str.Length); a++) { for (int b = 0; (b < str.Length); b++) { for (int c = 0; (c < str.Length); c++) { for (int d = 0; d < 3; d++) { for (int d1 = 3; d1 < 6; d1++) { string s111 = str[a].ToString() + str[b].ToString() + str[c].ToString() + str[d].ToString(); string s112 = str[a].ToString() + str[b].ToString() + str[c].ToString() + str[d1].ToString(); MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider(); Byte[] bytes4MD5 = Encoding.UTF8.GetBytes(s111); byte[] checkSum = md5.ComputeHash(bytes4MD5); string result = BitConverter.ToString(checkSum).Replace("-", String.Empty); if (result.ToLower().StartsWith(ac)) { Console.WriteLine(s111 + ":" + result.ToLower()); } } } } } } } 

I have this code, and there is only one problem: how can I ensure that not only the string s111 is hashed , but also the string s112 ?

PS Tried Byte[] bytes4MD5 = Encoding.UTF8.GetBytes(s111, s112); but the piece of iron does not understand such record.

  • NOT quite clear what you want? - Alexsandr Ter
  • Why stitch together and get a hash from the resulting string - Alexsandr Ter
  • @AlexsandrTer for software to hash the start of the string s111 and also s112 - komra23
  • @AlexsandrTer I just tried to do so that they say (s111 + s112), and the computer immediately understood .. - komra23
  • Or is this the answer to my question? - komra23

1 answer 1

ComputeHash() considers the hash and finalizes it. Re-use it will not work. To hash several data blocks, you need to call TransformBlock() , which adds data to the hash context and at the end - TransformFinalBlock() , which hash finalizes and returns the result

  • so how should it be? - komra23 2:42 pm
  • one
    @May_be in MSDN are examples. I do not see the point of copying them. - Vladimir Martyanov
  • Give a link to pzh, there are examples of how to make a hash from this number of strings? - komra23
  • 2
    @ May_be can and can, but isn't it better for you to learn yourself? - Vladimir Martyanov
  • one
    @May_be: you need to spend some time in order to gain basic interaction skills with www.google.com and MSDN. Without this, you will not be able to advance further in learning programming as such. - Artyom Ionash