From a2932784bb71e72a78c32819ebd7ed2bed551e3e Mon Sep 17 00:00:00 2001 From: Pratik Naik Date: Sun, 5 Oct 2008 22:16:26 +0100 Subject: Merge docrails --- activesupport/lib/active_support/base64.rb | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'activesupport/lib/active_support/base64.rb') diff --git a/activesupport/lib/active_support/base64.rb b/activesupport/lib/active_support/base64.rb index 602eef06b2..acb8e5a967 100644 --- a/activesupport/lib/active_support/base64.rb +++ b/activesupport/lib/active_support/base64.rb @@ -7,13 +7,24 @@ module ActiveSupport if defined? ::Base64 Base64 = ::Base64 else - # Ruby 1.9 doesn't provide base64, so we wrap this here + # Base64 provides utility methods for encoding and de-coding binary data + # using a base 64 representation. A base 64 representation of binary data + # consists entirely of printable US-ASCII characters. The Base64 module + # is included in Ruby 1.8, but has been removed in Ruby 1.9. module Base64 - + # Encodes a string to its base 64 representation. Each 60 characters of + # output is separated by a newline character. + # + # ActiveSupport::Base64.encode64("Original unencoded string") + # # => "T3JpZ2luYWwgdW5lbmNvZGVkIHN0cmluZw==\n" def self.encode64(data) [data].pack("m") end + # Decodes a base 64 encoded string to its original representation. + # + # ActiveSupport::Base64.decode64("T3JpZ2luYWwgdW5lbmNvZGVkIHN0cmluZw==") + # # => "Original unencoded string" def self.decode64(data) data.unpack("m").first end -- cgit v1.2.3