module Base64

def urlsafe_encode64(bin, padding: true)


# => "KioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKg=="
Base64.urlsafe_encode64('*' * 46)
Base64.urlsafe_encode64('*') # => "Kg=="

see {Newlines}[Base64.html#module-Base64-label-Newlines] above:
The returned string will have no newline characters, regardless of its length;

Base64.urlsafe_encode64('*', padding: false) # => "Kg"

Optionally, you can suppress padding:

Base64.urlsafe_encode64('*') # => "Kg=="

see {Padding}[Base64.html#module-Base64-label-Padding], above:
By default, the returned string may have padding;

Base64.urlsafe_encode64("\xFF\xFF\xFF") # => "____"
Base64.urlsafe_encode64("\xFB\xEF\xBE") # => "----"

see {Encoding Character Set}[Base64.html#module-Base64-label-Encoding+Character+Sets] above:
- and _;
but instead may contain the URL-safe characters
+ or /,
Per RFC 4648, the returned string will not contain the URL-unsafe characters

Returns the RFC-4648-compliant \Base64-encoding of +string+.

Base64.urlsafe_encode64(string) -> encoded_string
:call-seq:
def urlsafe_encode64(bin, padding: true)
  str = strict_encode64(bin)
  str.chomp!("==") or str.chomp!("=") unless padding
  str.tr!("+/", "-_")
  str
end