Module: Base64

Defined in:
lib/salmon.rb

Overview

Add URL safe Base64 support

Class Method Summary collapse

Class Method Details

.urlsafe_decode64(str) ⇒ Object

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 '/'.


20
21
22
# File 'lib/salmon.rb', line 20

def urlsafe_decode64(str)
  self.decode64(str.tr("-_", "+/"))
end

.urlsafe_encode64(bin) ⇒ Object

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 '/'.


12
13
14
# File 'lib/salmon.rb', line 12

def urlsafe_encode64(bin)
  self.strict_encode64(bin).tr("+/", "-_")
end