`
david01205
  • 浏览: 85705 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

Java Base64 实例

 
阅读更多
public class CodeContent {


/**
* 加密解密编码
*/


/**
* base64加密
* @param data 需要加密的字符串
* @return 加密处理后的字符串
* @throws UnsupportedEncodingException
*/
public static String encodeContent(String message)
throws UnsupportedEncodingException {
byte[] b = Base64.encodeBase64(message.getBytes("UTF-8"), true);
return new String(b, "UTF-8");
}

/**
* base64解密
* @param message 需要解密的字符串
* @return 解密处理后的字符串
* @throws UnsupportedEncodingException
*/
public static String decodeContent(String message)
throws UnsupportedEncodingException {
byte[] b = Base64.decodeBase64(message.getBytes("UTF-8"));
return new String(b, "UTF-8");
}


}
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics