You can certainly do something like the following for any size
document, streaming it in as you go:
#!/usr/bin/env ruby
require 'openssl'
key = "1234567890123456"
alg = "AES-128-CBC"
iv = "6543210987654321"
aes = OpenSSL::Cipher::Cipher.new(alg)
aes.encrypt
aes.key = key
aes.iv = iv
File.open("foo.enc",'w') do |enc|
File.open("foo") do |f|
loop do
r = f.read(4096)
break unless r
cipher = aes.update(r)
enc << cipher
end
end
enc << aes.final
end
Cheers,
Chris
On 15 Oct 2006, at 3:02 PM, Damjan Rems wrote:
>
> It looks like ruby openssl is not intended to encrypt large amount of
> data (like XML documents) because of:
>
> `private_encrypt': data too large for key size
> (OpenSSL::PKey::RSAError)
>
> Since there obvious are tools which do the job my question is. Can and
> how it be done with ruby?
>
>
> Thank you
>
> TheR
>
> --
> Posted via http://www.ruby-forum.com/.
>