public static void EncryptAndWriteFile(string originalText, string encryptFileoutPut, string reciverPublicKey, string senderPrivateKey, string senderSignaturePassword) { using (MemoryStream str = new MemoryStream()) { PgpEncryptionKeys objPgpEncryptionKeys = new PgpEncryptionKeys(reciverPublicKey, senderPrivateKey, senderSignaturePassword); PgpEncrypt objPgpEncrypt = new PgpEncrypt(objPgpEncryptionKeys); objPgpEncrypt.EncryptAndSign(str, originalText); SaveFileStream(encryptFileoutPut, str); str.Flush(); str.Close(); } }
public static byte[] Encrypt(string originalText, string reciverPublicKey, string senderPrivateKey, string senderSignaturePassword) { byte[] data; using (MemoryStream str = new MemoryStream()) { PgpEncryptionKeys objPgpEncryptionKeys = new PgpEncryptionKeys(reciverPublicKey, senderPrivateKey, senderSignaturePassword); PgpEncrypt objPgpEncrypt = new PgpEncrypt(objPgpEncryptionKeys); objPgpEncrypt.EncryptAndSign(str, originalText); data = str.ToArray(); str.Flush(); str.Close(); } return(data); }