hudi hudi - 23 days ago 9
Java Question

how to convert hex to base64

how to convert hex string into base64 ? I found this page http://home2.paulschou.net/tools/xlate/ but I need some function in java:

String base64 = ...decoder(String hex);
I found something in the Internet but they are to difficult and use byte array. I am looking for something simplier
thx a lot

Answer

Have a look at Commons Codec :

byte[] decodedHex = Hex.decodeHex(hex);
byte[] encodedHexB64 = Base64.codeBase64(decodedHex);
Comments