使用Apache commons-codec Base64实现加解密(转)
2017-04-27 13:54
246 查看
commons-codec是Apache下面的一个加解密开发包
官方地址为:http://commons.apache.org/codec/
官方下载地址:http://commons.apache.org/codec/download_codec.cgi
在线文档:http://commons.apache.org/codec/userguide.html
下面示例为使用Base64实现字符串的加解密:
/**
*
* 创建日期2011-4-25上午10:12:38
* 修改日期
* 作者:dh *TODO 使用Base64加密算法加密字符串
*return
*/
public static String encodeStr(String plainText){
byte[] b=plainText.getBytes();
Base64 base64=new Base64();
b=base64.encode(b);
String s=new String(b);
return s;
}
/**
*
* 创建日期2011-4-25上午10:15:11
* 修改日期
* 作者:dh *TODO 使用Base64加密
*return
*/
public static String decodeStr(String encodeStr){
byte[] b=encodeStr.getBytes();
Base64 base64=new Base64();
b=base64.decode(b);
String s=new String(b);
return s;
}
官方地址为:http://commons.apache.org/codec/
官方下载地址:http://commons.apache.org/codec/download_codec.cgi
在线文档:http://commons.apache.org/codec/userguide.html
下面示例为使用Base64实现字符串的加解密:
/**
*
* 创建日期2011-4-25上午10:12:38
* 修改日期
* 作者:dh *TODO 使用Base64加密算法加密字符串
*return
*/
public static String encodeStr(String plainText){
byte[] b=plainText.getBytes();
Base64 base64=new Base64();
b=base64.encode(b);
String s=new String(b);
return s;
}
/**
*
* 创建日期2011-4-25上午10:15:11
* 修改日期
* 作者:dh *TODO 使用Base64加密
*return
*/
public static String decodeStr(String encodeStr){
byte[] b=encodeStr.getBytes();
Base64 base64=new Base64();
b=base64.decode(b);
String s=new String(b);
return s;
}
相关文章推荐
- 使用Apache commons-codec Base64实现加解密
- 使用Apache commons-codec Base64实现加解密(转)
- 使用Apache commons-codec Base64实现加解密
- 使用commons-codec-1.10.jar的Base64实现字符串的加密解密
- java使用apache commons codec来进行Base64加密解密
- 使用Apache的Base64类实现Base64加解密
- 使用apache commons-codec base64将文件转为字符串
- Base64编码实现二---使用org.apache.tomcat.util.codec.binary.Base64实现Base64
- 使用 certutil 实现 Hex2Bin 和 Base64 加解密的方法
- 使用apache commons-fileupload.jar 实现文件上传
- JS实现base64加密解密
- 使用 T-SQL 实现 base64 解码
- 使用C#实现AES加密解密
- AES加解密算法,使用Base64做转码以及辅助加密
- 使用Apache Commons Net包实现javaFTP来上传目录
- 使用 T-SQL 实现 base64 解码
- Base64加密解密原理以及代码实现
- 使用apache commons-fileupload.jar 实现文件上传
- base64加密解密算法 C实现(转载)
- 使用apache commons-fileupload.jar 实现文件上传