From: Michal Suchanek Date: 2005-09-28T01:26:18+09:00 Subject: Re: How do I (really) encrypt a string in ruby? Hello Thanks for the example. Although ruby complains all the time about keyderivation with encrypt being deprecated I get at least to specify theiv. However, encrypting 2.0M file gives 2.1M file.Since doing encryption in C makes 2.0M ciphertext from 2.0M plaintext,and it is also possible to decrypt the 2.0M ciphertext to the originalplaintext, something is rotten here. Am I missing something? require "openssl" CHLEN = 256KBITS = 256KLEN = 32IVLEN = 16 # God knows why f=File.open("testkey");key=f.read(KLEN)f.closef=File.open("testiv")iv=f.read(IVLEN)f.closewhile (chunk=STDIN.read(CHLEN)) cipher=OpenSSL::Cipher::Cipher.new("AES-256-CBC") cipher.encrypt(key,iv) cipher.key=key cipher.iv=iv STDOUT << cipher.update(chunk) STDOUT << cipher.final()end --Support the freedom of music! Maybe it's a weird genre you would not likeif you heared it .. but weird is *not* illegal.Maybe next time they will send a special forces commando to your picnic .... because they think you are weird. http://www.music-versus-guns.org http://en.policejnistat.cz