//VSTUPNE UDAJE
Kód: Vybrať všetko
private void backgroundWorker1_DoWork_1(object sender, DoWorkEventArgs e)
{
MD5 md5 = MD5.Create();
//vstupny hash
string input = textBox1.Text;
string hash = " ";
byte[] hashBytes;
MD5 md5 = MD5.Create();
char = "abcdefghijklmnopqrstuvwxyz0123456789";
char[] chars = char.ToCharArray();
string theword;
int iPasswordLength;
int iPossibilities = (int)Math.Pow((double)chars.Length, (double)iPasswordLength);Kód: Vybrať všetko
for (int i = 0; i < iPossibilities; i++)
{
theword = "";
int val = i;
for (int j = 0; j < iPasswordLength; j++)
{
int ch = val % chars.Length;
theword = chars[ch] + theword;
val = val / chars.Length;
if (iPasswordLength < numericUpDown1.Value && iPossibilities == i + 1)
{
j = 0;
i = 0;
iPasswordLength += 1;
//vypocita pocet kombinacii pre danu dlzku.
iPossibilities = (int)Math.Pow((double)chars.Length, (double)iPasswordLength);
}
}
//ak sa zavola zrusenie procesu
if (backgroundWorker1.CancellationPending)
{
e.Cancel = true;
return;
}
//pripravi slovo na vytvorenie hashu
byte[] inputBytes = Encoding.Default.GetBytes(theword.ToCharArray());
//vygeneruje hash
hashBytes = md5.ComputeHash(inputBytes);
hash = BitConverter.ToString(hashBytes).Replace("-", String.Empty);
//porovnanie vygenerovaneho hashu so vstupnym hashom
if (hash == input)
{
found = 1;
e.Cancel = true;
return;
}
}
}