MD5值加密并转为16进制
来源:互联网 发布:中世纪手机游戏知乎 编辑:程序博客网 时间:2024/06/04 00:21
加密方式:MD5值
二进制转十六进制
private static MessageDigest digest = null;/** * Hashes a String using the Md5 algorithm and returns the result as a * String of hexadecimal numbers. This method is synchronized to avoid * excessive MessageDigest object creation. If calling this method becomes a * bottleneck in your code, you may wish to maintain a pool of MessageDigest * objects instead of using this method. * <p> * A hash is a one-way function -- that is, given an input, an output is * easily computed. However, given the output, the input is almost * impossible to compute. This is useful for passwords since we can store * the hash and a hacker will then have a very hard time determining the * original password. * <p> * In Jive, every time a user logs in, we simply take their plain text * password, compute the hash, and compare the generated hash to the stored * hash. Since it is almost impossible that two passwords will generate the * same hash, we know if the user gave us the correct password or not. The * only negative to this system is that password recovery is basically * impossible. Therefore, a reset password method is used instead. * * @param data * the String to compute the hash of. * @return a hashed version of the passed-in String */public synchronized static final String hash(String data) {if (digest == null) {try {digest = MessageDigest.getInstance("MD5");} catch (NoSuchAlgorithmException nsae) {System.err.println("Failed to load the MD5 MessageDigest. "+ "Jive will be unable to function normally.");nsae.printStackTrace();}}// Now, compute hash.digest.update(data.getBytes());return toHex(digest.digest());}/** * Turns an array of bytes into a String representing each byte as an * unsigned hex number. * <p> * Method by Santeri Paavolainen, Helsinki Finland 1996<br> * (c) Santeri Paavolainen, Helsinki Finland 1996<br> * Distributed under LGPL. * * @param hash * an rray of bytes to convert to a hex-string * @return generated hex string */public static final String toHex(byte hash[]) {StringBuffer buf = new StringBuffer(hash.length * 2);int i;for (i = 0; i < hash.length; i++) {if (((int) hash[i] & 0xff) < 0x10) {buf.append("0");}buf.append(Long.toString((int) hash[i] & 0xff, 16));}return buf.toString();}
0 0
- MD5值加密并转为16进制
- MD5加密,并转换为16进制
- c# 将json中的数据转为键值的形式放入字典Dictionary并进行拼接md5加密
- MD5加密并转换成16进制字符
- MD5加密并转换成16进制字符
- MD5加密,并以16进制返回
- java MD5加密,并转化为16进制字符
- MD5序列后的值转为32位16进制数
- MD5加密以及转化为16进制
- md5 16 位加密
- Android MD5值加密
- 盐值加密-MD5
- 盐值加密-MD5
- MD5盐值加密
- MD5盐值加密
- MD5加密并指定字符编码
- loadrunner-md5签名加密并转大写
- MD5加密的16位
- ArcEngine组合选中相邻图形
- 读《Boost程序库完全开发指南》笔记
- Source Insight下载及注册码
- Linux 定时任务
- tomcat 中文url路径
- MD5值加密并转为16进制
- 第15周 项目3-玩指针(2)
- 第十五周项目oj
- 2015
- 第十五周项目三OJ题目(3)
- iOS中app图标圆角半径
- python 网络爬虫问题
- 第15周项目1
- 十五周项目二 2