Node Dev Tools在解密文件时完全变黑

时间:2017-07-23 08:09:56

标签: javascript c# node.js encryption electron

我有一个程序使用C#解密一堆文件,使用电子边缘的html / js / css用户界面。

在解密过程中的某个时刻,开发工具窗口变为全黑。我的程序的UI仍然响应,但开发工具已经消失。 f5 快捷方式也不起作用。

它在第5个文件的解密开始时崩溃。有什么方法可以在执行任何操作时(包括内存限制或smth)在没有任何通知或错误消息的情况下崩溃:

    byte[] passwordBytes = System.Text.Encoding.UTF8.GetBytes(Password);
    byte[] salt = new byte[32];

    FileStream fsCrypt = new FileStream(InputFile, FileMode.Open);
    fsCrypt.Read(salt, 0, salt.Length);

    RijndaelManaged AES = new RijndaelManaged();

    AES.KeySize = 256;
    AES.BlockSize = 128;

    var key = new Rfc2898DeriveBytes(passwordBytes, salt, Constants.Encryption.HashIterations);
    AES.Key = key.GetBytes(AES.KeySize / 8);
    AES.IV = key.GetBytes(AES.BlockSize / 8);
    AES.Padding = PaddingMode.PKCS7;
    AES.Mode = CipherMode.CFB;

    CryptoStream cs = new CryptoStream(fsCrypt, AES.CreateDecryptor(), CryptoStreamMode.Read);

    FileStream fsOut = new FileStream(OutputFile, FileMode.Create);


    int read;
    byte[] buffer = new byte[1048576];

    try
    {
        long totalBytes = new FileInfo(InputFile).Length;
        long readBytes = 0;

        int progress = 0;
        int progress_last = 0;

        while ((read = cs.Read(buffer, 0, buffer.Length)) > 0)
        {
            if ((bool) await cm.isCancelled(null))
            {
                Console.WriteLine("Extraction was cancelled ...");
                await Progress.reset(new { type = CURRENT });
                (new FileInfo(LogFile)).Directory.Create();
                File.AppendAllText(LogFile, "Extraction was cancelled ...");
                break;
            }
            readBytes += read;
            fsOut.Write(buffer, 0, read);

            progress = getProgress(readBytes, totalBytes);



            if ((progress - progress_last) > PROGRESS_STEPSIZE || progress == 100)
            {
                await Progress.setProgress(new { type = CURRENT, value = progress });
                progress_last = progress;
            }

            // PROGRAM DOESN'T REACH THIS POINT
            Console.WriteLine("Decrypting: " + progress + " %");

        }
    }
    catch (System.Security.Cryptography.CryptographicException ex_CryptographicException)
    {
    // ... and so on an so forth. All errors are handled accordingly and will at minimum Console.Writeline() it. No error shows up. ...

关于这可能来自哪里的任何想法?如果我只是解密文件而不先下载它们(通过程序),一切正常......

另一个注意事项:前4个文件每个30-40 mb,第5个文件是90mb。

非常感谢任何帮助!

0 个答案:

没有答案