From: Michal Suchanek Date: 2005-09-28T02:08:54+09:00 Subject: Re: How do I (really) encrypt a string in ruby? On 9/27/05, Roland Schmitt wrote: > ..>> Example:>> require "openssl"> include OpenSSL> include Cipher>> cipher = Cipher.new("AES-256-CBC")>> key = cipher.random_key()> iv = cipher.random_iv()>>> #---- Encrypt> text = "Hello, World!"> cipher.encrypt(key,iv)Is the above the preferred way to set key and iv, or the below?Is it possible to set new iv (or key) without creating a new cipher instance?> cipher.key=key> cipher.iv = iv> e = cipher.update(text)> e << cipher.final() Is it possible to add more text after final()? I guess not. But as I understand it in C the encryption is done in chunks (probably16 or 32 bytes long). If I encrypt part of data (rounded to chunks),save the iv, and later encrypt some more data with the saved iv andthe same key, I can concatenate the results. And decrypting the concatenated results should give concatenation ofthe encrypted pieces of data. I haven't tried. But that's how I wouldexpect the iv to work. Now in ruby one gets final() which looks like it finishes off theinstance, and it is not apparent if the iv before final() or afterfinal() (or neither) could be used for continuing the encryption. 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