md5 加密工具类
来源:互联网 发布:mysql if函数用法 编辑:程序博客网 时间:2024/06/05 09:24
安全加密方式 MD5 ,关键词 不可逆 彩虹表 加盐
package test.test.util;import java.security.MessageDigest;public class Md5Util { /* * public static int getLocation(String[] fields, String field) { if (fields == * null || fields.length == 0) { return -1; } for (int i = 0; i < * fields.length; i++) { //System.out.println(fields[i]); if * (fields[i].indexOf(field) != -1) { //System.out.println("i:" + i); return * i; } } return -1; } */ private final static String[] hexDigits = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f" }; public static String byteArrayToHexString(byte[] b) { StringBuffer resultSb = new StringBuffer(); for (int i = 0; i < b.length; i++) { resultSb.append(byteToHexString(b[i])); } return resultSb.toString(); } private static String byteToHexString(byte b) { int n = b; if (n < 0) n = 256 + n; int d1 = n / 16; int d2 = n % 16; return hexDigits[d1] + hexDigits[d2]; } /** * MD5Encode * @param origin * @return MD5 code */ public static String MD5Encode(String origin) { String resultString = null; try { resultString = new String(origin); MessageDigest md = MessageDigest.getInstance("MD5"); resultString = byteArrayToHexString(md.digest(resultString .getBytes())); } catch (Exception ex) { } return resultString; }}
阅读全文
0 0
- MD5 加密工具类
- Md5加密工具类
- MD5加密工具类
- MD5加密工具类
- MD5加密工具类
- MD5 加密工具类
- MD5 加密工具类
- md5 加密工具类
- MD5加密工具类
- 工具类:MD5加密
- MD5加密工具类
- MD5加密工具类
- MD5加密工具类
- MD5加密工具类
- MD5加密工具类
- MD5加密工具类
- MD5加密工具类
- MD5加密工具类
- Stall Reservations
- PAT a1005题解
- 如何定义一个只能在栈/堆上生成对象的类
- 通过URL实现下载
- java基础之数字处理类
- md5 加密工具类
- Prime Ring Problem
- python 简单图像处理(13) 二值图腐蚀和膨胀,开运算、闭运算
- JSP学习笔记(4)_HTTP协议
- 最小表示法, 求字典序最小
- C++并发编程框架Theron(4)——Hello world!
- 比较三个数大小
- Scrapy-常用命令
- apache AH01630: client denied by server configuration错误解决方法