Ejemplo n.º 1
0
        private void btnRunDecrypt_Click(object sender, EventArgs e)
        {
            //break when paths are missing:
            if (txtKeyfilePath.Text == null && txtDecryptFilePath.Text == null)
            {
                return;
            }
            //continue when paths are given.

            //load the key file and file to decrypt:
            rwBinaryFile rwB = new rwBinaryFile();

            byte[]   keyFileData         = rwB.readBinaryFile(txtKeyfilePath.Text.ToString());
            UInt32[] sourceFileToDecrypt = rwB.readEncryptedFile(txtDecryptFilePath.Text.ToString());

            //now decrypt the file:
            FileCrypt FC = new FileCrypt();

            byte[] originalData = FC.decryptFile(keyFileData, sourceFileToDecrypt);

            //create filepath with correct extention:
            string FileExtention = rwB.getEncryptedFileExtention(txtDecryptFilePath.Text);
            string saveFilepath  = saveFileToPath("Data Files (*." + FileExtention + ")|*." + FileExtention, FileExtention);

            //now write the data like an original file:
            rwB.writeBinaryFile(saveFilepath, originalData);
        }
Ejemplo n.º 2
0
        //backgroundworker ID3:
        private void Bw3_DoWork(object sender, DoWorkEventArgs e)
        {
            byte[] _sourceFileToEncrypt = (byte[])e.Argument; //retrieve needed data as argument.

            FileCrypt FC = new FileCrypt();

            UInt32[] encryptedData = FC.encryptFile(keyFileData, _sourceFileToEncrypt, bw3);

            //send data to RunWorkerCompleted:
            e.Result = encryptedData;
        }