base64对字符串加密/解密

base64对字符串加密/解密


base64加密

String jsonStr = "123";
Bas64.Encoder encoder = Base64.getEncoder();
String decode = encoder.encodeToString(jsonStr.getBytes());

base64解密

String resultJson = "123";
String jsonStr = new String(Base64.getDecoder().decode(resultJson.getBytes()),"utf-8");
//        Base64.Decoder decoder = Base64.getDecoder();
//        byte[] decode = decoder.decode(jsonStr);

你可能感兴趣的:(java)