2017-10-02 7 views
0

私は、次のモジュールruby​​-gpgmeでfile_pathをどのように暗号化できますか?

https://github.com/ueno/ruby-gpgme

を使用して、私の暗号化コードベースはこのようなものです:

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 

私はどのように代わりに平文ファイルの入力ファイルパスをにないアイデアを持っていません。

アドバイスをいただければ幸いです。

答えて

0

暗号化のコンテキストにおける「プレーンテキスト」は、実際のテキストを参照するのではなく、暗号化する通常のデータを参照します。ファイルの内容を渡すだけです。plaintext

encrypt_sign(File.read(file_path), recipient_pubkey, ...) 
関連する問題