A quick thought, do browsers deal with binary data okay in parameter strings? XORing byte-wise will give you the full range of byte values.
I've not tried this, but you might run into trouble with browsers misinterpreting a 0x00 byte, or thinking that a byte with the 0x80 bit set is the start of a multi-byte character, especially on older browsers. Perhaps just base64 encoding <http://code.google.com/p/javascriptbase64/>the data might be a safer option? (Trivial to decode in ruby.<http://ruby-doc.org/stdlib-1.9.3/libdoc/base64/rdoc/Base64.html> ) Or, if you're only passing scores as numbers, you could always just obfuscate it mathematically--maybe apply a polynomial function which you can easily reverse on the client side. - alex. On Sun, Jun 24, 2012 at 11:04 AM, markbrown4 <[email protected]> wrote: > 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. > -- m: 0402 024 304 t: @kuperov -- 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.
