Ejemplo n.º 1
0
        private void Decrypt()
        {
            try
            {
                SetNote("Decrypting... Please wait.", 0);

                _inProgress        = true;
                _decryptSuccessful = false;

                while (!backgroundDecrypt.CancellationPending)
                {
                    FAES.FileAES_Decrypt decrypt = new FAES.FileAES_Decrypt(_fileToPeek, passwordInput.Text, false, true);

                    _pathOverride = Path.Combine(Path.GetDirectoryName(_fileToPeek.getPath()), "faesPeekFilePath_" + new Random().Next(), "peekFile" + FileAES_Utilities.ExtentionUFAES);
                    string dirName = Path.GetDirectoryName(_pathOverride);
                    _finalPath = Path.Combine(dirName, _fileToPeek.GetOriginalFileName());

                    DirectoryInfo di = Directory.CreateDirectory(dirName);
                    di.Attributes = FileAttributes.Directory | FileAttributes.Hidden;

                    Thread dThread = new Thread(() =>
                    {
                        try
                        {
                            _decryptSuccessful = decrypt.decryptFile(_pathOverride);
                        }
                        catch (Exception e)
                        {
                            SetNote(FileAES_Utilities.FAES_ExceptionHandling(e), 3);
                        }
                    });
                    dThread.Start();

                    while (dThread.ThreadState == ThreadState.Running)
                    {
                        _progress = decrypt.GetDecryptionPercentComplete();
                    }

                    backgroundDecrypt.CancelAsync();
                }
            }
            catch (Exception e)
            {
                SetNote(FileAES_Utilities.FAES_ExceptionHandling(e), 3);
            }
        }