Correction: in 1.8.7 no error is produced but the final_key is not correct: ruby-1.8.7-p174 > key = "test key" => "test key" ruby-1.8.7-p174 > final_key = "\0" * 16 => "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" ruby-1.8.7-p174 > key.length.times do |i| ruby-1.8.7-p174 > final_key[i%16] ^= key[i] ruby-1.8.7-p174 ?> end => 8 ruby-1.8.7-p174 > final_key => "test key\000\000\000\000\000\000\000\000" Joshua Mckinney wrote: > Having no luck with this. Getting the following error when generating > they key in 1.8.7 and 1.9.1. Any help would be much appreciated. > > > > ruby-1.9.1-p378 > key = "test_key" > => "test_key" > ruby-1.9.1-p378 > final_key = "\0" * 16 > => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" > ruby-1.9.1-p378 > key.length.times do |i| > ruby-1.9.1-p378 > final_key[i%16] ^= key[i] > ruby-1.9.1-p378 ?> end > NoMethodError: undefined method `^' for "\x00":String > from (irb):89:in `block in irb_binding' > from (irb):88:in `times' > from (irb):88 > > ruby-1.9.1-p378 > final_key > => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" > > > > > -- Posted via http://www.ruby-forum.com/.