public async Task WorkWithImageFileByteArrayTestAsync()
{
var progressEncrypt = new Progress<StreamCryptorTaskAsyncProgress>();
var progressDecrypt = new Progress<StreamCryptorTaskAsyncProgress>();
progressEncrypt.ProgressChanged +=
(s, e) => { Console.WriteLine("Encrypting: " + e.ProgressPercentage + "%\n"); };
progressDecrypt.ProgressChanged +=
(s, e) => { Console.WriteLine("Decrypting: " + e.ProgressPercentage + "%\n"); };
var rawFile = Path.Combine(TestContext.CurrentContext.TestDirectory, "Testfiles", "MyAwesomeChipmunkKiller.jpg");
var outputDirectory = Path.Combine(TestContext.CurrentContext.TestDirectory, "Testfiles", "decrypted");
const string privateKey = "31d9040b00a170532929b37db0afcb989e4175f96e5f9667ee8cbf5706679a71";
const string publicKey = "6d0deec730700f9f60687a4e6e8755157ca22ea2f3815b9bf14b1fe9ae6a0b4d";
var keyPair = new KeyPair(Utilities.HexToBinary(publicKey), Utilities.HexToBinary(privateKey));
Console.Write("Encrypting testfile . . .\n");
var encryptedFile =
await
Cryptor.EncryptFileWithStreamAsync(keyPair.PrivateKey, keyPair.PublicKey,
Utilities.HexToBinary(publicKey), rawFile, progressEncrypt, outputDirectory, ".test", true);
Console.Write("Decrypting testfile . . .\n");
var decryptedFileObject =
await
Cryptor.DecryptFileWithStreamAsync(keyPair.PrivateKey,
Path.Combine(TestContext.CurrentContext.TestDirectory, outputDirectory, encryptedFile),
progressDecrypt);
Console.Write("Get checksum of testfiles . . .\n");
Assert.AreEqual(Utils.GetChecksum(rawFile), Utils.GetChecksum(decryptedFileObject.FileData));
//clear garbage
File.Delete(Path.Combine(TestContext.CurrentContext.TestDirectory, outputDirectory, encryptedFile));
}