public static Stream EncryptSingleFile(SecureString passphrase, Stream contentsToEncrypt, string fileName, DateTime fileDateTime) { var msOutput = new MemoryStream(); var keyPacket = new SymmetricKeyEncryptedSessionKeyOpenPgpPacket(); keyPacket.WriteTo(msOutput); var literalData = new LiteralDataOpenPgpPacket(); literalData.FileName = fileName; literalData.FileDate = fileDateTime; contentsToEncrypt.CopyTo(literalData.LiteralStream); var compressedPacket = new CompressedDataOpenPgpPacket(); literalData.WriteTo(compressedPacket.DecompressedStream); var symmetricAlgorithm = keyPacket.GetKeyedSymmetricAlgorithm(passphrase); var outerPacket = new SymmetricallyEncryptedIntegrityProtectedDataOpenPgpPacket(); outerPacket.EncryptPackets(symmetricAlgorithm, compressedPacket); outerPacket.WriteTo(msOutput); msOutput.Position = 0; return(msOutput); }
public CompressedDataOpenPgpPacket Compress() { var compressed = new CompressedDataOpenPgpPacket(); WriteTo(compressed.DecompressedStream); return(compressed); }
public static Stream EncryptSingleFile(SecureString passphrase, Stream contentsToEncrypt, string fileName, DateTime fileDateTime) { var msOutput = new MemoryStream(); var keyPacket = new SymmetricKeyEncryptedSessionKeyOpenPgpPacket(); keyPacket.WriteTo(msOutput); var literalData = new LiteralDataOpenPgpPacket(); literalData.FileName = fileName; literalData.FileDate = fileDateTime; contentsToEncrypt.CopyTo(literalData.LiteralStream); var compressedPacket = new CompressedDataOpenPgpPacket(); literalData.WriteTo(compressedPacket.DecompressedStream); var symmetricAlgorithm = keyPacket.GetKeyedSymmetricAlgorithm(passphrase); var outerPacket = new SymmetricallyEncryptedIntegrityProtectedDataOpenPgpPacket(); outerPacket.EncryptPackets(symmetricAlgorithm, compressedPacket); outerPacket.WriteTo(msOutput); msOutput.Position = 0; return msOutput; }
public CompressedDataOpenPgpPacket Compress() { var compressed = new CompressedDataOpenPgpPacket(); WriteTo(compressed.DecompressedStream); return compressed; }