From: Michal Suchanek Date: 2005-09-28T02:20:48+09:00 Subject: Re: How do I (really) encrypt a string in ruby? On 9/27/05, Bill Kelly wrote:> From: "Michal Suchanek" >> > 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 original> > plaintext, something is rotten here.>> Any chance you're using Windows? Maybe it's a "text mode" vs. "binary mode" I am on OS X right now.> problem? (LF -> CRLF in the output)>> If you're on Windows, try:>> STDIN.binmode> STDOUT.binmodeThat does not help (not surprising). irb(main):010:0> c=OpenSSL::Cipher::Cipher.new("AES-256-CBC")=> #irb(main):011:0> c.encrypt(c.random_key(),c.random_iv())=> #irb(main):012:0> str='0123456789ABCDEF'=> "0123456789ABCDEF"irb(main):013:0> e=c.update(str+str)=> "\021\203\262\321\232@;Z-\257\020\240\343\350@s\236\322d\312U\246ce\221\331\034\2538@h\303"irb(main):014:0> e+=c.final()=> "\021\203\262\321\232@;Z-\257\020\240\343\350@s\236\322d\312U\246ce\221\331\034\2538@h\303\213L\036\2510b\006\353\307b\261#\022\257B\255"irb(main):015:0> e.length=> 48 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