Ruby 1.9.x undefined method ^ for string

1.3k views Asked by At

i found a ruby encryption library which is using this function.

def process(text)  
  0.upto(text.length-1) {|i| text[i] = text[i] ^ round}  
  text  
end

in ruby 1.9.x it throws an error - undefined method ^' for "\x1A":String__

is there any work around in ruby 1.9.x?

after googling i came to know that "In Ruby 1.9 string[index] returns character not code of the character (like it was in 1.8)." (https://rails.lighthouseapp.com/projects/8994/tickets/3144-undefined-method-for-string-ror-234)

Thanks in advance

1

There are 1 answers

2
cam On BEST ANSWER