Reputation: 1
I used the following module
https://github.com/ueno/ruby-gpgme
and my encryption code base is something like this:
def encrypt_sign(
plaintext,
recipient_pubkey,
sender_privkey,
binary: nil,
password: nil
)
in_a_directory(binary) do
options = pinentry_mode(password)
GPGME::Ctx.new(options) do |ctx|
import(sender_privkey)
import(recipient_pubkey)
ctx.add_signer(*(find(sender_privkey, :secret)))
ctx.encrypt_sign(
find(recipient_pubkey, :public),
data(plaintext),
data,
GPGME::ENCRYPT_ALWAYS_TRUST
).to_s
end
end
end
I have no idea how to input file path instead of plaintext file.
any advice is appreciated.
Upvotes: 0
Views: 182
Reputation: 22375
"Plaintext" in the context of cryptography doesn't refer to actual text but rather to the regular data you want encrypted. So all it should take is passing the file contents as plaintext
encrypt_sign(File.read(file_path), recipient_pubkey, ...)
Upvotes: 0