Skip to content

Instantly share code, notes, and snippets.

@rudolph9
Last active December 18, 2015 19:39
Show Gist options
  • Save rudolph9/5834907 to your computer and use it in GitHub Desktop.
Save rudolph9/5834907 to your computer and use it in GitHub Desktop.
com.write_message( ("\x02" + 6.chr + "AE5X:W" + ("AE5X:W" ^ 6.chr) + "\x03").force_encoding("ASCII-8BIT"))
class ::String
###
# @return the first charater in the string as an integer
def byte
self.bytes[0]
end
###
# XOR two strings
# @str assumed to be a one byte string or integer
def ^ str
if str.class == String
str = str.byte
elsif str.class == Fixnum
nil
else
raise "invalid arg: #{str.class} \n Must be String or Fixnum"
end
self.bytes.each do |i|
str = str ^ i
end
str.chr.force_encoding( "ASCII-8BIT")
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment