how to convert hex to base64

后端 未结 5 1224
天涯浪人
天涯浪人 2020-12-01 14:55

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 h

5条回答
  •  清歌不尽
    2020-12-01 15:03

    Have a look at 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);
    

提交回复
热议问题