// public void OnFileEncrypted(object source, HashArgs e) // { // MessageBox.Show("lol"); // MD5HASH hash = new MD5HASH(e.fileName); // string fileName = Path.GetFileName(e.fileName); // string fileHash = hash.BeginHashing(); // byte[] stringBytes = Encoding.UTF8.GetBytes(fileName + " " + fileHash + Environment.NewLine); // CreateHashFile(stringBytes); // // } public void OnFileEncrypted(string file) { MD5HASH hash = new MD5HASH(file); string fileName = Path.GetFileName(file); string fileHash = hash.BeginHashing(); byte[] stringBytes = Encoding.UTF8.GetBytes(fileName + " " + fileHash + Environment.NewLine); CreateHashFile(stringBytes); }
private async void StartDecryptionButton_Click(object sender, EventArgs e) { foreach (var file in Directory.GetFiles(PathTextBox.Text).Where(name => !name.EndsWith("HashValues.txt"))) { var progressIndicator = new Progress <int>(Report); MD5HASH hash = new MD5HASH(file); string encFileHash = hash.BeginHashing(); var filesToDecrypt = new List <string>(); if (CheckDecriptingFileHash(encFileHash)) { // byte[] decrypted = AEScrypto.Decrypt(File.ReadAllBytes(file)); // File.WriteAllBytes(PathTextBox.Text + @"\" + Path.GetFileName(file), decrypted); filesToDecrypt.Add(file); //if (!file.EndsWith("BuffZip.rar")) continue; } else { MessageBox.Show($"Failas, kurio parašas yra: {encFileHash} - pakeistas!"); } // cts = new CancellationTokenSource(); try { await listener.EncryptBytesAsync(progressIndicator, cts.Token, "Decrypt", PathTextBox.Text, filesToDecrypt.ToArray()); if (File.Exists(PathTextBox.Text + @"\BuffZip.rar")) { Zipper zip = new Zipper(PathTextBox.Text); zip.ExtractDirectories(); } } catch (OperationCanceledException ex) { MessageBox.Show(ex.Message, "Cancelled"); } } MessageBox.Show("Failai atkoduoti"); }