如何将hex转换为base64

hud*_*udi 14 java base64

如何将十六进制字符串转换为base64?我找到了这个页面http://home2.paulschou.net/tools/xlate/但是我需要java中的一些功能:String base64 = ...decoder(String hex);我在互联网上找到了一些东西,但它们很难并且使用字节数组.我正在寻找一些简单的东西

Vic*_*nez 25

看看Commons Codec:

 import org.apache.commons.codec.binary.Base64;
 import org.apache.commons.codec.binary.Hex;

byte[] decodedHex = Hex.decodeHex(hex);
byte[] encodedHexB64 = Base64.encodeBase64(decodedHex);
Run Code Online (Sandbox Code Playgroud)