Почему код работает не корректно? [требует правки]

446
13 января 2017, 07:08

Надо чтобы софт находил хеш даже если заменил комбинации, но почему-то он и не находит, не знаю почему..

using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Security.Cryptography;
namespace find_hash
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        private string MD5Digest(string data)
        {
            MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
            byte[] result = md5.ComputeHash(Encoding.Default.GetBytes(data));
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < result.Length; i++)
                sb.Append(result[i].ToString("x2"));
            return sb.ToString();
        }
        static string MD5(string s)
        {
            MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
            Byte[] bytes4MD5 = Encoding.UTF8.GetBytes(s);
            byte[] checkSum = md5.ComputeHash(bytes4MD5);
            return BitConverter.ToString(checkSum).Replace("-", String.Empty);
        }
        private void button1_Click(object sender, EventArgs e)
        {
            StreamReader stroka = new StreamReader(@"C:\Users\Alan\Desktop\mdfive.txt");
            textBox1.Text = stroka.ReadLine();
            string text = File.ReadAllText(@"C:\Users\Alan\Desktop\strings.txt");
            string shifr = MD5(text).ToLower();
            if (textBox1.Text==shifr)
            {
                textBox2.Text = text.ToString();
            }
            text = text.Replace("words111", "words112");
            File.WriteAllText(@"C:\Users\Alan\Desktop\strings.txt", text);
            if (textBox1.Text == shifr)
            {
                textBox2.Text = text.ToString();
            }
            text = text.Replace("words112", "words113");
            File.WriteAllText(@"C:\Users\Alan\Desktop\strings.txt", text);
            if (textBox1.Text == shifr)
            {
                textBox2.Text = text.ToString();
            }
            text = text.Replace("words113", "words114");
            File.WriteAllText(@"C:\Users\Alan\Desktop\strings.txt", text);
            if (textBox1.Text == shifr)
            {
                textBox2.Text = text.ToString();
            }
            text = text.Replace("words114", "words115");
            File.WriteAllText(@"C:\Users\Alan\Desktop\strings.txt", text);
            if (textBox1.Text==shifr)
            {
                textBox2.Text = text.ToString();
            }
            List<string> list = new List<string>();
            list.AddRange(File.ReadAllLines(@"C:\Users\Alan\Desktop\strings.txt"));
            string s = string.Empty;
            string a = string.Empty;
            textBox1.Text = textBox1.Text.ToLower();
            for (int i = 0; i < list.Count; i++)
            {
                s = list[i];
                a = MD5Digest(s);
                if (a == textBox1.Text)
                {
                    textBox2.Text = s;
                    break;
                }
            }
        }
    }
}
READ ALSO
usercontrol с различными шаблонами данных

usercontrol с различными шаблонами данных

добрый деньЕсть некоторый объект, приходящий от сервера вк

317
Создать изображение контрола

Создать изображение контрола

Мне нужно создать изображение контролаДелаю таким образом

304
С# таймер в отдельном потоке

С# таймер в отдельном потоке

При обновлении данных хотелось бы видеть сколько времени прошло от старта до завершенияИ видеть в онлайн времени

363