As seen in this HowTo, the sun.misc.BASE64Encoder/Decoder or creating your own Base64 handling are common ways to deal with Base64 encoding/decoding.
Here some alternatives which are maybe easier (and safer) to use.
Using java.util.Base64
Uses "The Base64 Alphabet" as specified in Table 1 of RFC 4648 and RFC 2045 for encoding and decoding operation. The encoder does not add any line feed (line separator) character. The decoder rejects data that contains characters outside the base64 alphabet.
Uses the "The Base64 Alphabet" as specified in Table 1 of RFC 2045 for encoding and decoding operation. The encoded output must be represented in lines of no more than 76 characters each and uses a carriage return '\r' followed immediately by a linefeed '\n' as the line separator. No line separator is added to the end of the encoded output. All line separators or other characters not found in the base64 alphabet table are ignored in decoding operation.
Uses the "URL and Filename safe Base64 Alphabet" as specified in Table 2 of RFC 4648 for encoding and decoding. The encoder does not add any line feed (line separator) character. The decoder rejects data that contains characters outside the base64 alphabet.
Using javax.xml.bind.DatatypeConverter
Using javax.mail.internet.MimeUtility
Using Apache Commons Codec
MiGBase64 is a very fast Base64 Codec written in Java. http://migbase64.sourceforge.net/.
Written and compiled by Réal Gagnon ©1998-2017
Комментариев нет: