Is Java 8 java.util.Base64 a drop-in replacement for sun.misc.BASE64?

前端 未结 4 1616
遇见更好的自我
遇见更好的自我 2020-12-25 11:00

Question

Are the Java 8 java.util.Base64 MIME Encoder and Decoder a drop-in replacement for the unsup

4条回答
  •  天涯浪人
    2020-12-25 11:33

    There are no changes to the base64 specification between rfc1521 and rfc2045.

    All base64 implementations could be considered to be drop-in replacements of one another, the only differences between base64 implementations are:

    1. the alphabet used.
    2. the API's provided (e.g. some might take only act on a full input buffer, while others might be finite state machines allowing you to continue to push chunks of input through them until you are done).

    The MIME base64 alphabet has remained constant between RFC versions (it has to or older software would break) and is: ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz+/

    As Wikipedia notes, only the last 2 characters may change between base64 implementations.

    As an example of a base64 implementation that does change the last 2 characters, the IMAP MUTF-7 specification uses the following base64 alphabet: ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz+,

    The reason for the change is that the / character is often used as a path delimiter and since the MUTF-7 encoding is used to flatten non-ASCII directory paths into ASCII, the / character needed to be avoided in encoded segments.

提交回复
热议问题