Added support for base64Encode

This commit is contained in:
Shekhar Gulati
2016-05-16 18:25:20 +05:30
parent 8fda832b80
commit 9ce0b2287c
2 changed files with 21 additions and 0 deletions
+12
View File
@@ -302,9 +302,21 @@ public abstract class Strman {
* @return decoded data
*/
public static String base64Decode(final String value) {
validate(value, NULL_STRING_PREDICATE, NULL_STRING_MSG_SUPPLIER);
return new String(Base64.getDecoder().decode(value));
}
/**
* Encodes data with MIME base64.
*
* @param value The data to encode
* @return The encoded String
*/
public static String base64Encode(final String value) {
validate(value, NULL_STRING_PREDICATE, NULL_STRING_MSG_SUPPLIER);
return Base64.getEncoder().encodeToString(value.getBytes());
}
private static long countSubstr(String value, String subStr, boolean allowOverlapping, long count) {
int position = value.indexOf(subStr);
if (position == -1) {