Beispiel #1
0
        private void btnHashText_Click(object sender, EventArgs e)
        {
            if (ParentHashTypeSelected == HashType.NONE)
            {
                MessageBox.Show("Invalid Hash Type selected on main form");
                return;
            }
            HashTools ht = new HashTools();

            ht.CreateTextHash(this.tbxHashText.Text, ParentHashTypeSelected);
            if (ht.InError)
            {
                MessageBox.Show("Hashing Error: " + ht.ErrorMsg);
                return;
            }
            CalculatedHash = ht.Hash;
            this.Close();
        }
Beispiel #2
0
        private void ActionCreateHash()
        {
            // Verify there is a file value and the file exists, then calculate the hash
            if (!(tbxFile.Text.Length > 0 && System.IO.File.Exists(tbxFile.Text)))
            {
                MessageBox.Show(String.Format("File textbox empty or file doesn't exist. ({0})", tbxFile.Text));
                return;
            }
            HashTools ht    = new HashTools();
            HashType  htype = GetSelectedHashType();

            if (HashType.NONE == htype)
            {
                MessageBox.Show("Invalid Hash Type");
                return;
            }
            Cursor.Current = Cursors.WaitCursor;
            ht.CreateFileHash(tbxFile.Text, htype);
            if (ht.InError)
            {
                // Throw Error
                MessageBox.Show("ERROR: " + ht.ErrorMsg);
                Cursor.Current = Cursors.Default;
                return;
            }
            Cursor.Current         = Cursors.Default;
            this.tbxFilesHash.Text = ht.Hash;
            if (Properties.Settings.Default.CopyHashToClipboard && !string.IsNullOrEmpty(ht.Hash))
            {
                Clipboard.SetText(ht.Hash);
            }
            currentFolder = ht.PathToFileToHash;
            if (Properties.Settings.Default.CheckLikeTextfileForHash) //TODO:Check how setting works when removed from config file
            {
                if (ht.FindTextHashFile(htype))
                {
                    tbxCompareHash.Text = ht.TextFileHashFound;
                    lblStatus.Text      = string.Format("Hash value found in file {0}", ht.TextFileFound);
                }
            }
        }