Closed paritoshnagar2016 closed 6 months ago
Hi, DecryptStream
is just a pointer to Decrypt
.
Running some test code on a similar size file I'm seeing decryption times of around 2 seconds for each method.
using PgpCore.Tests;
using System.Diagnostics;
namespace PgpCore.Debug;
internal class Program
{
static void Main(string[] args)
{
TestFactory testFactory = new TestFactory();
// Generate a 30MB file
testFactory.Arrange(FileType.GeneratedSmall);
PGP pgp = new PGP();
pgp.GenerateKey(
testFactory.PublicKeyFileInfo,
testFactory.PrivateKeyFileInfo,
testFactory.UserName,
testFactory.Password
);
EncryptionKeys encryptionKeys = new EncryptionKeys(testFactory.PublicKey, testFactory.PrivateKey, testFactory.Password);
PGP pgpEncrypt = new PGP(encryptionKeys);
using (Stream outputFileStream = testFactory.EncryptedContentFileInfo.Create())
pgpEncrypt.Encrypt(testFactory.ContentStream, outputFileStream);
// Record time to decrypt
Stopwatch stopwatch = new Stopwatch();
stopwatch.Start();
using (Stream outputFileStream = testFactory.DecryptedContentFileInfo.Create())
pgpEncrypt.Decrypt(testFactory.EncryptedContentStream, outputFileStream);
stopwatch.Stop();
Console.WriteLine($"Decryption using Decrypt took {stopwatch.ElapsedMilliseconds}ms");
// 3128ms
// Reset
testFactory.DecryptedContentFileInfo.Delete();
stopwatch.Reset();
stopwatch.Start();
using (Stream outputFileStream = testFactory.DecryptedContentFileInfo.Create())
pgpEncrypt.DecryptStream(testFactory.EncryptedContentStream, outputFileStream);
stopwatch.Stop();
Console.WriteLine($"Decryption using DecryptStream took {stopwatch.ElapsedMilliseconds}ms");
// 2406ms
}
}
If you can provide a fully working example demonstrating the issue I'll take another look.
I am using DecryptStream that runs very slowly like take around 1.3 mins to complete 26 MD data, but when I try pgp.Decrypt it completes in 2 sec. Is there way I can improve performance using DecryptStream