From: "Jan E." Date: 2012-05-17T05:39:00+09:00 Subject: Re: what is going wrong here? The case of the noob not understanding initialize Hi, What's your Ruby version? If you actually get different output for the three variants (which you shouldn't), then this might be a bug in the OpenSSL class. You should note, however, that your code will do the following: It takes the string "whatever" as the plaintext, encrypts it, then takes the encrypted string as the plaintext and encrypts it again. So your output will be something like whatever (first plaintext) ABC (encryped "whatever") ABC (second plaintext = encrypted "whatever") XYZ (encrypted ABC) If that's not what you want, then you have to change your code. This might be a good idea, anyway. You seem to be confused about when to use instance variables, because most of them simply don't make any sense. In the first class, you create the instance variable @ciphertext in the encrypt method, but you use it nowhere. Then what do you need it for? In the second class, you have the @sha256 variable, but you overwrite it on every method call. This makes no sense. A local variable is what you want. Use instance variables *only* if you actually want to store a value persistently inside the object. Do *not* use them to pass values to methods or whatever. -- Posted via http://www.ruby-forum.com/.