-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path5-1.linq
35 lines (32 loc) · 930 Bytes
/
5-1.linq
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<Query Kind="Program">
<Namespace>System.Security.Cryptography</Namespace>
</Query>
void Main()
{
string input = "cxdnnyjw";
string password = string.Empty;
int index = 0;
using (var md5 = MD5.Create())
{
while (password.Length < 8)
{
char? next = GetNext(md5, string.Concat(input, index.ToString()));
if (next.HasValue) password += next;
index++;
}
}
password.Dump();
}
char? GetNext(MD5 md5, string inputString)
{
var inputBytes = Encoding.UTF8.GetBytes(inputString);
var hashBytes = md5.ComputeHash(inputBytes);
StringBuilder sb = new StringBuilder();
for (int i = 0; i < hashBytes.Length; i++)
{
sb.Append(hashBytes[i].ToString("x2"));
}
string hash = sb.ToString();
if (hash[0] == '0' && hash[1] == '0' && hash[2] == '0' && hash[3] == '0' && hash[4] == '0') return hash[5];
return null;
}