Program.cs 914 B

1234567891011121314151617181920212223242526272829303132333435
  1. using System;
  2. using System.Security.Cryptography;
  3. using System.Text;
  4. namespace D05._1
  5. {
  6. class Program
  7. {
  8. static byte[] ToB(string str) => Encoding.ASCII.GetBytes(str);
  9. static string ToS(byte[] b) => BitConverter.ToString(b).Replace("-", "");
  10. static void Main(string[] args)
  11. {
  12. if (args.Length < 1) throw new ArgumentException();
  13. string input = args[0];
  14. var sb = new StringBuilder();
  15. using (var md5 = MD5.Create())
  16. {
  17. int i = 0;
  18. while (sb.Length < 8)
  19. {
  20. var h = md5.ComputeHash(ToB($"{input}{i}"));
  21. var sh = ToS(h);
  22. if (sh.StartsWith("00000")) sb.Append(sh[5]);
  23. i++;
  24. }
  25. }
  26. Console.WriteLine($"Password is : {sb.ToString()}");
  27. }
  28. }
  29. }