class Mail::Encodings::Base64

Base64 encoding handles binary content at the cost of 4 output bytes per input byte.

Constants

NAME
PRIORITY

Public Class Methods

can_encode?(enc) click to toggle source
# File lib/mail/encodings/base64.rb, line 14
def self.can_encode?(enc)
  true
end
compatible_input?(str) click to toggle source

Ruby Base64 inserts newlines automatically, so it doesn’t exceed SMTP line length limits.

# File lib/mail/encodings/base64.rb, line 33
def self.compatible_input?(str)
  true
end
cost(str) click to toggle source

3 bytes in -> 4 bytes out

# File lib/mail/encodings/base64.rb, line 27
def self.cost(str)
  4.0 / 3
end
decode(str) click to toggle source
# File lib/mail/encodings/base64.rb, line 18
def self.decode(str)
  Utilities.decode_base64(str)
end
encode(str) click to toggle source
# File lib/mail/encodings/base64.rb, line 22
def self.encode(str)
  ::Mail::Utilities.binary_unsafe_to_crlf(Utilities.encode_base64(str))
end