Method: SecurizeString::Base64Methods::InstanceMethods#from_base64
- Defined in:
- lib/securize_string/base64_methods.rb
#from_base64(opts = {}) ⇒ Object
Decodes from base64.
By default, this decodes the normal RFC 2045 Base64.
If the url_safe option is set to true, then it decodes the RFC 4648 encoding, which uses a slightly different encoding mechanism which is sometimes compatible, but often incompatible with RFC 2045.
40 41 42 43 44 |
# File 'lib/securize_string/base64_methods.rb', line 40 def from_base64(opts={}) raise ArgumentError, "__method__ expects an argument hash but got #{opts.class.name}" unless opts.kind_of?(Hash) string = (opts[:url_safe] ? urlsafe_decode64(self) : Base64.decode64(self)) return self.class.new(string) end |