Added convenience methods:

- String encode(String raw)
 - String decode(String raw)
This commit is contained in:
aum
2005-03-23 06:21:16 +00:00
committed by zzz
parent 5b83aed719
commit 08ee62b52c

View File

@ -42,6 +42,10 @@ public class Base64 {
private final static Log _log = new Log(Base64.class); private final static Log _log = new Log(Base64.class);
/** added by aum */
public static String encode(String source) {
return encode(source.getBytes());
}
public static String encode(byte[] source) { public static String encode(byte[] source) {
return encode(source, 0, (source != null ? source.length : 0)); return encode(source, 0, (source != null ? source.length : 0));
} }
@ -55,6 +59,10 @@ public class Base64 {
return safeEncode(source, off, len, useStandardAlphabet); return safeEncode(source, off, len, useStandardAlphabet);
} }
/** convenience method added by aum */
public static String decode(String s) {
return new String(decode(s));
}
public static byte[] decode(String s) { public static byte[] decode(String s) {
return safeDecode(s, false); return safeDecode(s, false);
} }