/**
* 加密
* @param str
* @return
*/
public static String getStr(String str){
BASE64Encoder base64 = new BASE64Encoder();
return base64.encode(str.getBytes());
}
/**
* 解密
* @param str
* @return
* @throws IOException
*/
public static String getDeStr(String str) throws IOException{
BASE64Decoder base64 = new BASE64Decoder();
return new String(base64.decodeBuffer(str));
}
本文介绍了一种使用Base64进行字符串加密和解密的方法。提供了两个关键函数:getStr用于加密,getDeStr用于解密。通过Base64Encoder和BASE64Decoder类实现了对输入字符串的编码和解码。
3万+

被折叠的 条评论
为什么被折叠?



