Module: Base64

Defined in:
lib/el_finder/base64.rb

Overview

Note:

stdlib module.

The Base64 module provides for the encoding (encode64, strict_encode64, urlsafe_encode64) and decoding (decode64, strict_decode64, urlsafe_decode64) of binary data using a Base64 representation.

Class Method Summary collapse

Class Method Details

.urlsafe_decode64(str) ⇒ Object

Note:

This method will be defined only on ruby 1.8 due to its absence in stdlib.

Returns the Base64-decoded version of str. This method complies with “Base 64 Encoding with URL and Filename Safe Alphabet” in RFC 4648. The alphabet uses ‘-’ instead of ‘+’ and ‘_’ instead of ‘/’.



19
20
21
# File 'lib/el_finder/base64.rb', line 19

def self.urlsafe_decode64(str)
  str.tr("-_", "+/").unpack("m0").first
end

.urlsafe_encode64(bin) ⇒ Object

Note:

This method will be defined only on ruby 1.8 due to its absence in stdlib.

Returns the Base64-encoded version of bin. This method complies with “Base 64 Encoding with URL and Filename Safe Alphabet” in RFC 4648. The alphabet uses ‘-’ instead of ‘+’ and ‘_’ instead of ‘/’.



13
14
15
# File 'lib/el_finder/base64.rb', line 13

def self.urlsafe_encode64(bin)
  [bin].pack("m0").tr("+/", "-_")
end