Last active
December 18, 2015 19:39
-
-
Save rudolph9/5834907 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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