lib/ronin/formatting/extensions/binary/string.rb in ronin-0.1.1 vs lib/ronin/formatting/extensions/binary/string.rb in ronin-0.1.2
- old
+ new
@@ -55,9 +55,19 @@
return integer
end
#
+ # XOR encodes the string using the specified _key_.
+ #
+ def xor(key)
+ encoded = ''
+
+ each_byte { |b| encoded << (b ^ key).chr }
+ return encoded
+ end
+
+ #
# Returns the base64 encoded form of the string.
#
def base64_encode
Base64.encode64(self)
end