lib/ronin/formatting/extensions/binary/string.rb in ronin-0.1.4 vs lib/ronin/formatting/extensions/binary/string.rb in ronin-0.2.0
- old
+ new
@@ -19,10 +19,11 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#++
#
+require 'ronin/formatting/extensions/text'
require 'ronin/arch'
require 'base64'
class String
@@ -52,9 +53,19 @@
end
end
end
return integer
+ end
+
+ #
+ # Returns the hex escaped form of the string.
+ #
+ # "hello".hex_escape
+ # # => "\\x68\\x65\\x6c\\x6c\\x6f"
+ #
+ def hex_escape(options={})
+ format_bytes(options) { |b| "\\x%.2x" % b }
end
#
# XOR encodes the string using the specified _key_.
#