Example #1
0
        private void btnSelectFile_Click(object sender, EventArgs e)
        {
            if (btnFile.Checked)
            {
                if (ofdOpenFile.ShowDialog() == DialogResult.OK)
                {
                    txtString.ReadOnly = true;
                    txtString.Text     = "";

                    string fileName = ofdOpenFile.FileName;
                    txtFileName.Text = fileName;
                    txtMD5.Text      = FileHasher.MD5Hash(fileName);
                    txtSHA1.Text     = FileHasher.SHA1Hash(fileName);
                    txtSHA256.Text   = FileHasher.SHA256Hash(fileName);
                    txtSHA384.Text   = FileHasher.SHA384Hash(fileName);
                    txtSHA512.Text   = FileHasher.SHA512Hash(fileName);
                }
            }
        }
Example #2
0
        void TextBox1TextChanged(object sender, EventArgs e)
        {
            if (btnString.Checked)
            {
                try
                {
                    btnFile.Checked      = false;
                    txtFileName.ReadOnly = true;
                    txtFileName.Text     = "";
                    // Create a new instance of the MD5CryptoServiceProvider object.
                    MD5CryptoServiceProvider  md5    = new MD5CryptoServiceProvider();
                    SHA1CryptoServiceProvider sha1   = new SHA1CryptoServiceProvider();
                    SHA256Managed             sha256 = new SHA256Managed();
                    SHA384Managed             sha384 = new SHA384Managed();
                    SHA512Managed             sha512 = new SHA512Managed();

                    // Convert the input string to a byte array and compute the hash.
                    byte[] dataMd5    = md5.ComputeHash(Encoding.Default.GetBytes(txtString.Text));
                    byte[] dataSha1   = sha1.ComputeHash(Encoding.Default.GetBytes(txtString.Text));
                    byte[] dataSha256 = sha256.ComputeHash(Encoding.Default.GetBytes(txtString.Text));
                    byte[] dataSha384 = sha384.ComputeHash(Encoding.Default.GetBytes(txtString.Text));
                    byte[] dataSha512 = sha512.ComputeHash(Encoding.Default.GetBytes(txtString.Text));

                    txtMD5.Text    = FileHasher.GetHash(dataMd5);
                    txtSHA1.Text   = FileHasher.GetHash(dataSha1);
                    txtSHA256.Text = FileHasher.GetHash(dataSha256);
                    txtSHA384.Text = FileHasher.GetHash(dataSha384);
                    txtSHA512.Text = FileHasher.GetHash(dataSha512);
                }

                catch (Exception)
                {
                    MessageBox.Show("Error");
                }
            }

            ;
        }
Example #3
0
        private void MainForm_DragDrop(object sender, DragEventArgs e)
        {
            // Extract the data from the DataObject-Container into a string list
            string[] FileList = (string[])e.Data.GetData(DataFormats.FileDrop, false);

            btnFile.Checked       = true;
            txtString.ReadOnly    = true;
            txtString.Text        = "";
            txtFileName.ReadOnly  = false;
            btnSelectFile.Enabled = true;


            // Do something with the data...
            txtFileName.Text     = FileList[0];
            ofdOpenFile.FileName = FileList[0];
            string fileName = ofdOpenFile.FileName;

            txtMD5.Text    = FileHasher.MD5Hash(fileName);
            txtSHA1.Text   = FileHasher.SHA1Hash(fileName);
            txtSHA256.Text = FileHasher.SHA256Hash(fileName);
            txtSHA384.Text = FileHasher.SHA384Hash(fileName);
            txtSHA512.Text = FileHasher.SHA512Hash(fileName);
        }
        private void btnCompare_Click(object sender, EventArgs e)
        {
            if (btnMd5.Checked && fileName != "")
            {
                hashvalue = FileHasher.MD5Hash(fileName);
                ShowMsg(hashvalue, txtHash.Text);
            }

            else if (btnSha1.Checked && fileName != null)
            {
                hashvalue = FileHasher.SHA1Hash(fileName);
                ShowMsg(hashvalue, txtHash.Text);
            }

            else if (btnSha256.Checked && fileName != null)
            {
                hashvalue = FileHasher.SHA256Hash(fileName);
                ShowMsg(hashvalue, txtHash.Text);
            }

            else if (btnSha384.Checked && fileName != null)
            {
                hashvalue = FileHasher.SHA384Hash(fileName);
                ShowMsg(hashvalue, txtHash.Text);
            }

            else if (btnSha512.Checked && fileName != null)
            {
                hashvalue = FileHasher.SHA512Hash(fileName);
                ShowMsg(hashvalue, txtHash.Text);
            }
            else
            {
                MessageBox.Show("Enter all datas");
            }
        }