@@ -631,7 +631,8 @@ public static Bytes parseBase36(CharSequence base36String) {
631631 }
632632
633633 /**
634- * Parsing of base64 encoded byte arrays. Supporting RFC 3548 normal and url safe encoding.
634+ * Parsing of base64 encoded byte arrays.
635+ * Supporting RFC 4648 normal and url safe encoding, with or without padding.
635636 *
636637 * @param base64String the encoded string
637638 * @return decoded instance
@@ -1624,27 +1625,46 @@ public String encodeBase36() {
16241625
16251626 /**
16261627 * Base64 representation with padding. This is *NOT* the url safe variation. This encoding has a space efficiency of 75%.
1628+ *
1629+ * This encoding is <a href="https://tools.ietf.org/html/rfc4648">RFC 4648</a> compatible.
16271630 * <p>
16281631 * Example: <code>SpT9/x6v7Q==</code>
16291632 *
16301633 * @return base64 string
16311634 * @see <a href="https://en.wikipedia.org/wiki/Base64">Base64</a>
16321635 */
16331636 public String encodeBase64 () {
1634- return encode ( new BinaryToTextEncoding . Base64Encoding ( false , true ) );
1637+ return encodeBase64 ( false , true );
16351638 }
16361639
16371640 /**
1638- * Base64 representation with padding. This is the url safe variation subsitution '+' and '/' with '-' and '_'
1641+ * Base64 representation with padding. This is the url safe variation substitution '+' and '/' with '-' and '_'
16391642 * respectively. This encoding has a space efficiency of 75%.
1643+ *
1644+ * This encoding is <a href="https://tools.ietf.org/html/rfc4648">RFC 4648</a> compatible.
16401645 * <p>
16411646 * Example: <code>SpT9_x6v7Q==</code>
16421647 *
16431648 * @return base64 url safe string
16441649 * @see <a href="https://en.wikipedia.org/wiki/Base64">Base64</a>
16451650 */
16461651 public String encodeBase64Url () {
1647- return encode (new BinaryToTextEncoding .Base64Encoding (true , true ));
1652+ return encodeBase64 (true , true );
1653+ }
1654+
1655+ /**
1656+ * Base64 representation with either padding or without and with or without URL and filename safe alphabet.
1657+ * This encoding is <a href="https://tools.ietf.org/html/rfc4648">RFC 4648</a> compatible.
1658+ * <p>
1659+ * Example: <code>SpT9/x6v7Q==</code>
1660+ *
1661+ * @param urlSafe if true will substitute '+' and '/' with '-' and '_'
1662+ * @param withPadding if true will add padding the next full byte with '='
1663+ * @return base64 url safe string
1664+ * @see <a href="https://en.wikipedia.org/wiki/Base64">Base64</a>
1665+ */
1666+ public String encodeBase64 (boolean urlSafe , boolean withPadding ) {
1667+ return encode (new BinaryToTextEncoding .Base64Encoding (urlSafe , withPadding ));
16481668 }
16491669
16501670 /**
0 commit comments