/// <summary> /// Attempts to decrypt the contents of a data buffer. /// If required, the user will be prompted for a password using the default pinentry program. /// </summary> /// <param name="cipher">A DataBuffer containing the data to be decrypted.</param> /// <returns>A DataBuffer containing the decrypted data.</returns> public GpgBuffer Decrypt(GpgBuffer cipher) { var output = MemoryGpgBuffer.Create(); ErrorHandler.Check(GpgMeWrapper.gpgme_op_decrypt(Handle, cipher.Handle, output.Handle)); output.Position = 0; return(output); }
/// <summary> /// Attempts to encrypt the contents of a data buffer for multiple recipients. /// </summary> /// <param name="plain">A DataBuffer containing the plaintext data to be encrypted.</param> /// <param name="recipients">The GPG keys for which the data should be encrypted.</param> /// <param name="encryptFlags">The encryption flags to be used.</param> /// <returns>A DataBuffer containing the encrypted data.</returns> public GpgBuffer Encrypt(GpgBuffer plain, IEnumerable <GpgKey> recipients, EncryptFlags encryptFlags = EncryptFlags.None) { // Transform the recipient list into a list of GpgME key handles var rcpHandles = recipients.Select(rcp => rcp.Handle).ToArray(); var output = MemoryGpgBuffer.Create(); ErrorHandler.Check(GpgMeWrapper.gpgme_op_encrypt(Handle, rcpHandles, encryptFlags, plain.Handle, output.Handle)); output.Position = 0; return(output); }
/// <summary> /// Attempts to encrypt the contents of a data buffer for the given recipient. /// </summary> /// <param name="plain">A DataBuffer containing the plaintext data to be encrypted.</param> /// <param name="recipient">The GPG key for which the data should be encrypted.</param> /// <returns>A DataBuffer containing the encrypted data.</returns> public GpgBuffer Encrypt(GpgBuffer plain, GpgKey recipient) { return(Encrypt(plain, new[] { recipient })); }