So the Ruby equivalent is:
 
def xor(text, key)
  result = ""
  text.each_byte do |c|
    result += (key ^ c).chr;
  end
  result
end

The operators are the same, I must have been trying to use it with strings 
when it was failing.

Thanks again,

On Saturday, 23 June 2012 21:27:17 UTC+10, Clifford Heath wrote:
>
> On 23/06/2012, at 5:22 PM, Ivan Vanderbyl wrote: 
> > Isn't hat simply power operator? The ruby equiv should be ** 
> > On 23/06/2012, at 4:42 PM, markbrown4 <[email protected]> wrote: 
> >> I had a quick look for what the ^ operator does in Javascript but 
> couldn't find any info on it. 
> >> The ^ operator isn't available in Ruby 1.9.3 so I don't know what the 
> Ruby equivalent would look like. 
>
> It's exclusive-or, just like in C and Ruby. 
>
> Clifford Heath.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
or Rails Oceania" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/rails-oceania/-/UknI7p088R8J.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rails-oceania?hl=en.

Reply via email to