Class Base64Coder
This class is used to encode and decode data in Base64 format as described in RFC 1521.
Home page: www.source-code.biz
Author: Christian d'Heureuse, Inventec Informatik AG, Zurich, Switzerland
Multi-licensed: EPL/LGPL/AL/BSD.
Version history:
2003-07-22 Christian d'Heureuse (chdh): Module created.
2005-08-11 chdh: Lincense changed from GPL to LGPL.
2006-11-21 chdh:
Method encode(String) renamed to encodeString(String).
Method decode(String) renamed to decodeString(String).
New method encode(byte[],int) added.
New method decode(String) added.
2009-07-16: Additional licenses (EPL/AL) added.
2009-09-16: Additional license (BSD) added.
2009-09-16: Additional license (BSD) added.
2010-01-27: Package name added.
-
Method Summary
Modifier and TypeMethodDescriptionstatic byte[]
decode
(char[] in) Decodes a byte array from Base64 format.static byte[]
Decodes a byte array from Base64 format.static String
Decodes a string from Base64 format.static char[]
encode
(byte[] in) Encodes a byte array into Base64 format.static char[]
encode
(byte[] in, int iLen) Encodes a byte array into Base64 format.static String
Encodes a string into Base64 format.
-
Method Details
-
encodeString
Encodes a string into Base64 format. No blanks or line breaks are inserted.- Parameters:
s
- a String to be encoded.- Returns:
- A String with the Base64 encoded data.
-
encode
public static char[] encode(byte[] in) Encodes a byte array into Base64 format. No blanks or line breaks are inserted.- Parameters:
in
- an array containing the data bytes to be encoded.- Returns:
- A character array with the Base64 encoded data.
-
encode
public static char[] encode(byte[] in, int iLen) Encodes a byte array into Base64 format. No blanks or line breaks are inserted.- Parameters:
in
- an array containing the data bytes to be encoded.iLen
- number of bytes to process inin
.- Returns:
- A character array with the Base64 encoded data.
-
decodeString
Decodes a string from Base64 format.- Parameters:
s
- a Base64 String to be decoded.- Returns:
- A String containing the decoded data.
- Throws:
IllegalArgumentException
- if the input is not valid Base64 encoded data.
-
decode
Decodes a byte array from Base64 format.- Parameters:
s
- a Base64 String to be decoded.- Returns:
- An array containing the decoded data bytes.
- Throws:
IllegalArgumentException
- if the input is not valid Base64 encoded data.
-
decode
public static byte[] decode(char[] in) Decodes a byte array from Base64 format. No blanks or line breaks are allowed within the Base64 encoded data.- Parameters:
in
- a character array containing the Base64 encoded data.- Returns:
- An array containing the decoded data bytes.
- Throws:
IllegalArgumentException
- if the input is not valid Base64 encoded data.
-