Module: Ronin::Support::Encoding::Base64
- Defined in:
- lib/ronin/support/encoding/base64.rb
Overview
Class Method Summary collapse
-
.decode(data, mode: nil) ⇒ String
Base64 decodes the given data.
-
.encode(data, mode: nil) ⇒ String
Base64 encodes the given data.
Class Method Details
.decode(data, mode: nil) ⇒ String
Base64 decodes the given data.
71 72 73 74 75 76 77 78 79 |
# File 'lib/ronin/support/encoding/base64.rb', line 71 def self.decode(data, mode: nil) case mode when :strict then ::Base64.strict_decode64(data) when :url_safe then ::Base64.urlsafe_decode64(data) when nil then ::Base64.decode64(data) else raise(ArgumentError,"Base64 mode must be either :string, :url_safe, or nil: #{mode.inspect}") end end |
.encode(data, mode: nil) ⇒ String
Base64 encodes the given data.
49 50 51 52 53 54 55 56 57 |
# File 'lib/ronin/support/encoding/base64.rb', line 49 def self.encode(data, mode: nil) case mode when :strict then ::Base64.strict_encode64(data) when :url_safe then ::Base64.urlsafe_encode64(data) when nil then ::Base64.encode64(data) else raise(ArgumentError,"Base64 mode must be either :string, :url_safe, or nil: #{mode.inspect}") end end |