module Ronin::Support::Encoding::Base64
Base64
-
encoding/decoding.
[Base64]: en.wikipedia.org/wiki/Base64
## Core-Ext Methods
-
{String#base64_encode}
-
{String#base64_decode}
@api public
Public Class Methods
decode(data, mode: nil)
click to toggle source
Base64
decodes the given data.
@param [String] data
The Base64 data to decode.
@param [:strict, :url_safe, nil] mode
The Base64 encoding mode.
@return [String]
The decoded data.
# 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)
click to toggle source
Base64
encodes the given data.
@param [String] data
The data to Base64 encode.
@param [:strict, :url_safe, nil] mode
The Base64 encoding mode.
@return [String]
The Base64 encoded data.
# 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