commons-codec包简介
来源:互联网 发布:取个淘宝达人名字 编辑:程序博客网 时间:2024/05/11 14:02
包含一些通用的编码解码算法。包括一些语音编码器,Hex,Base64
commons-codec包可以从apache下载,最新版是1.3
不可逆算法
1.MD5
<!---->String str = "abc";
DigestUtils.md5Hex(str);
DigestUtils.md5Hex(str);
附.net生成MD5的方法,生成内容跟java一致:
<!---->String str = "abc";
FormsAuthentication.HashPasswordForStoringInConfigFile(str, "MD5");
FormsAuthentication.HashPasswordForStoringInConfigFile(str, "MD5");
2.SHA1
<!---->String str = "abc";
DigestUtils.shaHex(str);
DigestUtils.shaHex(str);
附.net生成SHA1的方式,生成内容跟java一致:
<!---->String str = "abc";
FormsAuthentication.HashPasswordForStoringInConfigFile(str, "SHA1");
FormsAuthentication.HashPasswordForStoringInConfigFile(str, "SHA1");
可逆算法
常规加密解密算法:BASE64
加密
<!---->String str= "abc"; // abc为要加密的字符串
byte[] b = Base64.encodeBase64(str.getBytes(), true);
System.out.println(new String(b));
byte[] b = Base64.encodeBase64(str.getBytes(), true);
System.out.println(new String(b));
解密
<!---->String str = "YWJj"; // YWJj为要解密的字符串
byte[] b = Base64.decodeBase64(str.getBytes());
System.out.println(new String(b));
byte[] b = Base64.decodeBase64(str.getBytes());
System.out.println(new String(b));
转载:http://blog.csdn.net/yigelangmandeshiren/article/details/8144438
0 0
- commons-codec包简介
- commons-codec包简介
- 【JavaWeb】commons-codec包简介
- 使用Commons-codec包加密
- 字符串编解码包----Commons-codec介绍
- commons包简介
- apache commons 包简介
- Apache commons包简介
- apache commons包简介
- apache commons包简介
- apache commons包简介
- apache commons-fileupload包简介
- apache commons Java包简介
- commons包的作用简介
- Apache commons 之 codec 简介和入门代码
- org.apache.commons.codec.digest.DigestUtils下载相关包
- Apache组件commons的Codec包的使用实例
- 使用commons-codec包加密字符串(MD5,SHA1,BASE64)
- Unity3D游戏开发之截屏保存精彩瞬间
- 欢迎使用CSDN-markdown编辑器
- openstack 配置项理解
- 解决TextView中MaxLines与ellipsize=end冲突问题
- xcode升级 插件修复
- commons-codec包简介
- Simple Rtmp Server的安装与简单使用
- 数据结构初步认识
- 232转can can-232 10年销量I厂家
- ogg- 因为机器重启而停掉
- Android Support V4, V7, V13的作用
- springMvc + Json整合配置 RESTful
- 版本控制器git学习笔记(二)Git的使用
- Oracle 静默安装方式