| 1234567891011121314151617181920212223242526272829303132333435 |
- using System;
- using System.IO;
- using System.Linq;
- using System.Security.Cryptography;
- using System.Text;
- namespace D04._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 hash = args[0];
- int nbr = 0;
- using (var md5 = MD5.Create())
- {
- do
- {
- var h = md5.ComputeHash(ToB($"{hash}{nbr}"));
- if (ToS(h).StartsWith("000000")) break;
- nbr++;
- } while (true);
- }
- Console.WriteLine($"Answer is : {nbr}");
- }
- }
- }
|