module Ronin::Support::Encoding::Base16
Base16
encoding.
## Core-Ext Methods
-
{String#base16_encode}
-
{String#base16_decode}
@see www.rfc-editor.org/rfc/rfc4648#page-10
@api public
@since 1.0.0
Public Class Methods
Source
# File lib/ronin/support/encoding/base16.rb, line 73 def self.decode(data) decoded = String.new(encoding: Encoding::ASCII_8BIT) data.scan(/../).each do |hex_char| decoded << hex_char.to_i(16).chr end return decoded end
@param [String] data
The given data to Base16 decode.
@return [String]
The Base16 decoded version of the String.
@example
Encoding::Base16.decode("68656C6C6F") # => "hello"
Source
# File lib/ronin/support/encoding/base16.rb, line 50 def self.encode(data) encoded = String.new data.each_byte do |byte| encoded << ("%.2x" % byte) end return encoded end
Base16
encodes the given data.
@param [String] data
The given data to Base16 encode.
@return [String]
The Base16 encoded version of the String.
@example
Encoding::Base16.encode("hello") # => "68656C6C6F"