I have a client file which is encrypted using PGP encryption. The encrypted file shared is in xlsx
format. The PGP private key is also shared as a text file(Note that i added .pgp
extension for the private key file).
I tried decrypting the file using the below code in the rails console:
crypto = GPGME::Crypto.new
GPGME::Key.import(File.open('private_key.pgp'))
cipthertext = GPGME::Data.new(File.open('encrypted_file.xlsx'))
data = crypto.decrypt cipthertext, {}
But the following error is coming when the last line is executed:
/.rvm/gems/ruby-3.1.2/gems/gpgme-2.0.24/lib/gpgme/ctx.rb:489:in `decrypt_verify': No secret key (GPGME::Error::NoSecretKey)
I’m using gpgme
gem version 2.0.24
Rails version: 7.0.8.1
I tried adding .gpg
extension for the encrypted file, renaming it to ‘encrypted_file.xlsx.gpg’ and tried the same steps again, but still showing the same error.
Is there any issues with the code or any issues with the file extensions that i’m using?
Thanks in advance