MimeKit.Cryptography.MultipartEncrypted.SignAndEncrypt C# (CSharp) Method

SignAndEncrypt() public static method

Create a multipart/encrypted MIME part by signing and encrypting the specified entity.
Signs the entity using the supplied signer and digest algorithm and then encrypts to the specified recipients, encapsulating the result in a new multipart/encrypted part.
/// is null. /// -or- /// is null. /// -or- /// is null. /// -or- /// is null. /// /// cannot be used for signing. /// -or- /// One or more of the recipient keys cannot be used for encrypting. /// -or- /// No recipients were specified. /// /// The was out of range. /// /// The is not supported. /// -or- /// The is not supported. /// /// The user chose to cancel the password prompt. /// /// 3 bad attempts were made to unlock the secret key. ///
public static SignAndEncrypt ( MimeKit.Cryptography.OpenPgpContext ctx, MailboxAddress signer, DigestAlgorithm digestAlgo, EncryptionAlgorithm cipherAlgo, IEnumerable recipients, MimeEntity entity ) : MultipartEncrypted
ctx MimeKit.Cryptography.OpenPgpContext The OpenPGP cryptography context to use for singing and encrypting.
signer MailboxAddress The signer to use to sign the entity.
digestAlgo DigestAlgorithm The digest algorithm to use for signing.
cipherAlgo EncryptionAlgorithm The encryption algorithm.
recipients IEnumerable The recipients for the encrypted entity.
entity MimeEntity The entity to sign and encrypt.
return MultipartEncrypted
		public static MultipartEncrypted SignAndEncrypt (OpenPgpContext ctx, MailboxAddress signer, DigestAlgorithm digestAlgo, EncryptionAlgorithm cipherAlgo, IEnumerable<MailboxAddress> recipients, MimeEntity entity)
		{
			if (ctx == null)
				throw new ArgumentNullException ("ctx");

			if (signer == null)
				throw new ArgumentNullException ("signer");

			if (recipients == null)
				throw new ArgumentNullException ("recipients");

			if (entity == null)
				throw new ArgumentNullException ("entity");

			using (var memory = new MemoryBlockStream ()) {
				var options = FormatOptions.CloneDefault ();
				options.NewLineFormat = NewLineFormat.Dos;

				entity.WriteTo (options, memory);
				memory.Position = 0;

				var encrypted = new MultipartEncrypted ();
				encrypted.ContentType.Parameters["protocol"] = ctx.EncryptionProtocol;

				// add the protocol version part
				encrypted.Add (new ApplicationPgpEncrypted ());

				// add the encrypted entity as the second part
				encrypted.Add (ctx.SignAndEncrypt (signer, digestAlgo, cipherAlgo, recipients, memory));

				return encrypted;
			}
		}

Same methods

MultipartEncrypted::SignAndEncrypt ( MailboxAddress signer, DigestAlgorithm digestAlgo, EncryptionAlgorithm cipherAlgo, IEnumerable recipients, MimeEntity entity ) : MultipartEncrypted
MultipartEncrypted::SignAndEncrypt ( MailboxAddress signer, DigestAlgorithm digestAlgo, IEnumerable recipients, MimeEntity entity ) : MultipartEncrypted
MultipartEncrypted::SignAndEncrypt ( MimeKit.Cryptography.OpenPgpContext ctx, MailboxAddress signer, DigestAlgorithm digestAlgo, IEnumerable recipients, MimeEntity entity ) : MultipartEncrypted
MultipartEncrypted::SignAndEncrypt ( MimeKit.Cryptography.OpenPgpContext ctx, PgpSecretKey signer, DigestAlgorithm digestAlgo, EncryptionAlgorithm cipherAlgo, IEnumerable recipients, MimeEntity entity ) : MultipartEncrypted
MultipartEncrypted::SignAndEncrypt ( MimeKit.Cryptography.OpenPgpContext ctx, PgpSecretKey signer, DigestAlgorithm digestAlgo, IEnumerable recipients, MimeEntity entity ) : MultipartEncrypted
MultipartEncrypted::SignAndEncrypt ( PgpSecretKey signer, DigestAlgorithm digestAlgo, EncryptionAlgorithm cipherAlgo, IEnumerable recipients, MimeEntity entity ) : MultipartEncrypted
MultipartEncrypted::SignAndEncrypt ( PgpSecretKey signer, DigestAlgorithm digestAlgo, IEnumerable recipients, MimeEntity entity ) : MultipartEncrypted