module HTTPX::Base64

  1. lib/httpx/base64.rb

require “base64” will not be a default gem after ruby 3.4.0

Methods

Public Instance

  1. decode64
  2. strict_encode64
  3. urlsafe_encode64

Public Instance methods

decode64(str)
[show source]
   # File lib/httpx/base64.rb
11 def decode64(str)
12   str.unpack1("m")
13 end
strict_encode64(bin)
[show source]
   # File lib/httpx/base64.rb
15 def strict_encode64(bin)
16   [bin].pack("m0")
17 end
urlsafe_encode64(bin, padding: true)
[show source]
   # File lib/httpx/base64.rb
19 def urlsafe_encode64(bin, padding: true)
20   str = strict_encode64(bin)
21   str.chomp!("==") or str.chomp!("=") unless padding
22   str.tr!("+/", "-_")
23   str
24 end