Module: UrlSafeBase64
- Defined in:
- lib/url_safe_base64.rb
Class Method Summary collapse
Class Method Details
.decode64(str) ⇒ Object
8 9 10 11 12 13 14 15 16 |
# File 'lib/url_safe_base64.rb', line 8 def self.decode64(str) case str.length.modulo(4) when 2 str += '==' when 3 str += '=' end Base64.decode64(str.gsub("-", "+").gsub("_", "/")) end |
.encode64(str) ⇒ Object
4 5 6 |
# File 'lib/url_safe_base64.rb', line 4 def self.encode64(str) Base64.encode64(str).gsub(/[\s=]+/, "").gsub("+", "-").gsub("/", "_") end |