From: Michal Suchanek Date: 2005-09-28T18:53:57+09:00 Subject: Re: How do I (really) encrypt a string in ruby? On 9/28/05, NAKAMURA, Hiroshi wrote:... >> > while (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>> This block should be:>> cipher=OpenSSL::Cipher::Cipher.new("AES-256-CBC")> cipher.encrypt(key,iv)> cipher.padding=0 # avoid PKCS#5 paddingyes, this is what I wanted> cipher.key=key> cipher.iv=iv> ciphertext = []> while (chunk=STDIN.read(CHLEN))> ciphertext << cipher.update(chunk)> end> ciphertext << cipher.final() rescue nil # no need to call final if> padding = 0> print ciphertext.join But I really want to encrypt (and decrypt) the blocks separately. Now I get identical results with C and ruby. Great ! Thanks Michal Suchanek --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