public string TransformToNewFile(string sourceFilePath) { string outputPath = $"{sourceFilePath}.{EncryptedExtensions}"; PgpEncryptor.EncryptFile(sourceFilePath, outputPath, _publicKey); return(outputPath); }
public void Can_encrypt_file() { using (var files = new TempFileCollection()) { string inputFilePath = files.AddFile(); string outputFilePath = files.AddFile(); WriteAllText(inputFilePath, "Hello Encryption"); PgpEncryptor.EncryptFile(inputFilePath, outputFilePath, TestKeys.PublicKey); outputFilePath.Should().BeExistingFilePath(); } }
public void Can_decrypt_file() { using (var files = new TempFileCollection()) { string inputFilePath = files.AddFile(); string encryptedFilePath = files.AddFile(); string decryptedFilePath = files.AddFile(); string content = $"Hello Decryption {Guid.NewGuid()}"; WriteAllText(inputFilePath, content); PgpEncryptor.EncryptFile(inputFilePath, encryptedFilePath, TestKeys.PublicKey); using (FileStream encryptedStream = OpenRead(encryptedFilePath)) using (FileStream privateKeyStream = OpenRead(TestKeys.PrivateKeyPath)) { PgpDecryptor.Decrypt(encryptedStream, privateKeyStream, TestKeys.Password, decryptedFilePath); } decryptedFilePath.Should().BePathToFileWithContent(content); } }