Module: Ronin::Support::Encoding::Base16
- Defined in:
- lib/ronin/support/encoding/base16.rb
Overview
Class Method Summary collapse
-
.decode(data) ⇒ String
Base16 decodes the String.
-
.encode(data) ⇒ String
Base16 encodes the given data.
Class Method Details
.decode(data) ⇒ String
Base16 decodes the String.
73 74 75 76 77 78 79 80 81 |
# 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 |
.encode(data) ⇒ String
Base16 encodes the given data.
50 51 52 53 54 55 56 57 58 |
# 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 |