def xor(text, key)
result = ""
text.each_byte do |c|
result += (key ^ c).chr;
end
result
end
This is not equivalent to the JavaScript code.
The JavaScript code operates on 16-bit code units, and this code
operates on 8-bit bytes. This will work only if all the code units in
the JavaScript string are in the range 0x0000 .. 0x007F, the key is also
in that range, and the Ruby string encoding represents code points in
the range U+0000 .. U+007F with one byte only (UTF-8, for example).
Thanks,
Nicholas
--
You received this message because you are subscribed to the Google Groups "Ruby or
Rails Oceania" group.
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.