public void Sign(MimeMessage message, PgpSecretKey key) { // digitally sign our message body using our custom GnuPG cryptography context using (var ctx = new MyGnuPGContext()) { message.Body = MultipartSigned.Create(ctx, key, DigestAlgorithm.Sha1, message.Body); } }
static Stream Decrypt(MimeMessage message) { var text = message.TextBody; using (var memory = new MemoryStream(Encoding.ASCII.GetBytes(text), false)) { using (var ctx = new MyGnuPGContext()) { return(ctx.GetDecryptedStream(memory)); } } }
public void Encrypt(MimeMessage message) { // encrypt our message body using our custom GnuPG cryptography context using (var ctx = new MyGnuPGContext()) { // Note: this assumes that each of the recipients has a PGP key associated // with their email address in the user's public keyring. // // If this is not the case, you can use SecureMailboxAddresses instead of // normal MailboxAddresses which would allow you to specify the fingerprint // of their PGP keys. You could also choose to use one of the Encrypt() // overloads that take a list of PgpPublicKeys. message.Body = MultipartEncrypted.Encrypt(ctx, message.To.Mailboxes, message.Body); } }
public void Encrypt (MimeMessage message) { // encrypt our message body using our custom GnuPG cryptography context using (var ctx = new MyGnuPGContext ()) { // Note: this assumes that each of the recipients has a PGP key associated // with their email address in the user's public keyring. // // If this is not the case, you can use SecureMailboxAddresses instead of // normal MailboxAddresses which would allow you to specify the fingerprint // of their PGP keys. You could also choose to use one of the Encrypt() // overloads that take a list of PgpPublicKeys. message.Body = MultipartEncrypted.Encrypt (ctx, message.To.Mailboxes, message.Body); } }
static Stream Decrypt(MimeMessage message) { var text = message.TextBody; using (var encrypted = new MemoryStream(Encoding.ASCII.GetBytes(text), false)) { using (var ctx = new MyGnuPGContext()) { var decrypted = new MemoryStream(); ctx.DecryptTo(encrypted, decrypted); decrypted.Position = 0; return(decrypted); } } }
public void Sign(MimeMessage message) { // digitally sign our message body using our custom GnuPG cryptography context using (var ctx = new MyGnuPGContext()) { // Note: this assumes that the Sender address has an S/MIME signing certificate // and private key with an X.509 Subject Email identifier that matches the // sender's email address. // // If this is not the case, you can use a SecureMailboxAddress instead of a // normal MailboxAddress which would allow you to specify the fingerprint // of the sender's private PGP key. You could also choose to use one of the // Create() overloads that take a PgpSecretKey, instead. var sender = message.From.Mailboxes.FirstOrDefault(); message.Body = MultipartSigned.Create(ctx, sender, DigestAlgorithm.Sha1, message.Body); } }
public void Sign (MimeMessage message) { // digitally sign our message body using our custom GnuPG cryptography context using (var ctx = new MyGnuPGContext ()) { // Note: this assumes that the Sender address has an S/MIME signing certificate // and private key with an X.509 Subject Email identifier that matches the // sender's email address. // // If this is not the case, you can use a SecureMailboxAddress instead of a // normal MailboxAddress which would allow you to specify the fingerprint // of the sender's private PGP key. You could also choose to use one of the // Create() overloads that take a PgpSecretKey, instead. var sender = message.From.Mailboxes.FirstOrDefault (); message.Body = MultipartSigned.Create (ctx, sender, DigestAlgorithm.Sha1, message.Body); } }
public void Sign (MimeMessage message, PgpSecretKey key) { // digitally sign our message body using our custom GnuPG cryptography context using (var ctx = new MyGnuPGContext ()) { message.Body = MultipartSigned.Create (ctx, key, DigestAlgorithm.Sha1, message.Body); } }
static Stream Decrypt (MimeMessage message) { var text = message.TextBody; using (var memory = new MemoryStream (Encoding.ASCII.GetBytes (text), false)) { using (var ctx = new MyGnuPGContext ()) { return ctx.GetDecryptedStream (memory); } } }