Thanks for the reply, we got rid of the error in 1.9.1 but both 1.9.1 
and 1.8.7 produce the wrong final_key

ruby-1.9.1-p378 >     final_key
 => "test key\x00\x00\x00\x00\x00\x00\x00\x00"

ruby-1.8.7-p174 >     final_key
 => "test key\000\000\000\000\000\000\000\000"

Rob Biedenharn wrote:
> On Jul 1, 2010, at 11:34 AM, Joshua Mckinney wrote:
>>>     final_key[i%16] ^= key[i]
>>> => true
>> ruby-1.9.1-p378 > key = "test_key"
>>
>> ruby-1.9.1-p378 >     final_key
>> => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
> 
> Because in Ruby 1.8.6, "hello"[0] is 104, but in 1.8.7 and 1.9.x,
> "hello"[0] is "h"
> 
> Change that line to:
> 
> final_key[i%16] = (final_key[i%16].ord ^ key[i].ord).chr
> 
> And you should get the right answer:
> 
> irb> x="hello"
> => "hello"
> irb> x[0] = (x[0].ord ^ 0x20).chr
> => "H"
> irb> x
> => "Hello"
> 
> String#ord gives the Fixnum value of a single-character string.
> Fixnum#chr gives the single-character String whose #ord is the Fixnum
> 
> (I'm sure the actual docs say that better ;-)
> 
> -Rob
> 
> Rob Biedenharn
> http://agileconsultingllc.com
>   Rob / AgileConsultingLLC.com
> http://gaslightsoftware.com
>   rab / GaslightSoftware.com

-- 
Posted via http://www.ruby-forum.com/.