Advertisement
Guest User

kekekke

a guest
Feb 8th, 2016
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.09 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Security.Cryptography;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7.  
  8. namespace ConsoleApplication1
  9. {
  10. class Program
  11. {
  12. static void Main(string[] args)
  13. {
  14. Console.Write("anna md5 tiiviste: ");
  15. string salasana = Console.ReadLine();
  16.  
  17. string tulos = "";
  18. string merkit = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
  19. string tiiviste = "";
  20. bool onnistui = false;
  21.  
  22.  
  23. if (salasana.Length == 32)
  24. {
  25. int purkuaika = 0;
  26. while(purkuaika <= 1)
  27. {
  28.  
  29. purkuaika++;
  30. Console.WriteLine("purkamisen aloitus: " + DateTime.Now);
  31. break;
  32.  
  33. }
  34. foreach (char ch1 in merkit)
  35. {
  36.  
  37.  
  38. tulos = "" + ch1;
  39. byte[] vou = new UTF8Encoding().GetBytes(tulos);
  40. byte[] kek = ((HashAlgorithm)CryptoConfig.CreateFromN­ame("MD5")).ComputeHash(vou);
  41. tiiviste = BitConverter.ToString(kek).Replace("-", string.Empty).ToLower();
  42.  
  43. if (tiiviste == salasana)
  44. {
  45. onnistui = true;
  46. goto Lopetus;
  47. }
  48. foreach (char ch2 in merkit)
  49. {
  50. tulos = "" + ch1 + ch2;
  51. byte[] vou2 = new UTF8Encoding().GetBytes(tulos);
  52. byte[] kek2 = ((HashAlgorithm)CryptoConfig.CreateFromN­ame("MD5")).ComputeHash(vou2);
  53. tiiviste = BitConverter.ToString(kek2).Replace("-", string.Empty).ToLower();
  54. if (tiiviste == salasana)
  55. {
  56. onnistui = true;
  57. goto Lopetus;
  58. }
  59. foreach (char ch3 in merkit)
  60. {
  61. tulos = "" + ch1 + ch2 + ch3;
  62. byte[] vou3 = new UTF8Encoding().GetBytes(tulos);
  63. byte[] kek3 = ((HashAlgorithm)CryptoConfig.CreateFromN­ame("MD5")).ComputeHash(vou3);
  64. tiiviste = BitConverter.ToString(kek3).Replace("-", string.Empty).ToLower();
  65. if (tiiviste == salasana)
  66. {
  67. onnistui = true;
  68. goto Lopetus;
  69. }
  70. foreach (char ch4 in merkit)
  71. {
  72. tulos = "" + ch1 + ch2 + ch3 + ch4;
  73. byte[] on = new UTF8Encoding().GetBytes(tulos);
  74. byte[] vou4 = ((HashAlgorithm)CryptoConfig.CreateFromN­ame("MD5")).ComputeHash(on);
  75. tiiviste = BitConverter.ToString(vou2).Replace("-", string.Empty).ToLower();
  76. if (tiiviste == salasana)
  77. {
  78. onnistui = true;
  79. goto Lopetus;
  80. }
  81. foreach (char ch5 in merkit)
  82. {
  83. tulos = "" + ch1 + ch2 + ch3 + ch4 + ch5;
  84. byte[] vou5 = new UTF8Encoding().GetBytes(tulos);
  85. byte[] kek5 = ((HashAlgorithm)CryptoConfig.CreateFromN­ame("MD5")).ComputeHash(vou5);
  86. tiiviste = BitConverter.ToString(kek5).Replace("-", string.Empty).ToLower();
  87.  
  88.  
  89. if (tiiviste == salasana)
  90. {
  91. onnistui = true;
  92. goto Lopetus;
  93.  
  94. }
  95. else if (tulos == "zzzz")
  96. {
  97.  
  98. }
  99.  
  100. }
  101. }
  102. }
  103. }
  104. }
  105. }
  106. Lopetus:
  107.  
  108. if (tulos != "" && onnistui)
  109. Console.Write("salasana on: " + tulos + " ");
  110.  
  111.  
  112. else if (tulos != "")
  113. Console.WriteLine("salasanaa ei onnistuttu murtamaan");
  114. else
  115.  
  116. Console.Write("et antanu oikeanlaista md5 tiivistettä");
  117. goto end;
  118.  
  119. end:
  120. Console.WriteLine("purkamisen lopetus: " + DateTime.Now);
  121. Console.ReadLine();
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129. }
  130. }
  131. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement