Created
May 23, 2012 10:19
-
-
Save awilmore/2774446 to your computer and use it in GitHub Desktop.
Java Base64 Utils
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.awilmore.stringutils; | |
import static javax.xml.bind.DatatypeConverter.parseBase64Binary; | |
import static javax.xml.bind.DatatypeConverter.printBase64Binary; | |
public class Base64Util { | |
public static String decode(String encoded) { | |
byte[] decoded = parseBase64Binary(encoded); | |
return new String(decoded); | |
} | |
public static String encode(String decoded) { | |
return printBase64Binary(decoded.getBytes()); | |
} | |
public static byte[] decodeBinary(String encoded) { | |
return parseBase64Binary(encoded); | |
} | |
public static String encodeBinary(byte[] decoded) { | |
return printBase64Binary(decoded); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment