| 123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- using System;
- using System.Security.Cryptography;
- using System.Text;
- namespace D05._2
- {
- class Program
- {
- static byte[] ToB(string str) => Encoding.ASCII.GetBytes(str);
- static string ToS(byte[] b) => BitConverter.ToString(b).Replace("-", "");
- static void Main(string[] args)
- {
- if (args.Length < 1) throw new ArgumentException();
- string input = args[0];
- var password = new char[8];
- int found = 0;
- using (var md5 = MD5.Create())
- {
- int i = 0;
- while (found < 8)
- {
- var h = md5.ComputeHash(ToB($"{input}{i}"));
- var sh = ToS(h);
- if (sh.StartsWith("00000") && sh[5] < '8')
- {
- int p = sh[5] - '0';
- if (password[p] == '\0')
- {
- found++;
- password[p] = sh[6];
- }
- }
- i++;
- }
- }
- Console.WriteLine($"Password is : {string.Join("", password)}");
- }
- }
- }
|