use*_*003 6 ruby encryption gnupg openpgp
试图将一些旧的shell/unix脚本转换为Ruby.
我对通过Unix中的gpg工具完成的文件进行了以下加密.我可以传入收件人密钥,我要加密的文件,以及pgp的outfile加密东西.
gpg --recipient "$my_recipient_key" \
--encrypt "$my_file" \
--output "$my_outfile" \
--always-trust \
--compress-algo zip
Run Code Online (Sandbox Code Playgroud)
与上面的简单加密相比,Ruby相当于什么?
做了一些挖掘后,我看到:
谢谢!
我最近用过gpgme.加密文件的代码如下所示
GPGME::Key.import(File.open(path_to_key)) #only needed if the key has not been imported previously
crypto = GPGME::Crypto.new :always_trust => true
File.open(path_to_encrypt) do |in_file|
File.open(output_path, 'wb') do |out_file|
crypto.encrypt in_file, :output => out_file, :recipients => "foo@example.com"
end
end
Run Code Online (Sandbox Code Playgroud)
你可能想知道什么没有"认证"关于什么是rubygems - 任何人都可以在那里发布一个宝石(并且需要3分钟才能完成)
| 归档时间: |
|
| 查看次数: |
4681 次 |
| 最近记录: |