MD5 32位大写
来源:互联网 发布:算法竞赛入门经典在线 编辑:程序博客网 时间:2024/04/29 16:45
package com.wop.web.controller;import java.security.MessageDigest;import java.security.NoSuchAlgorithmException;/* * MD5 算法*/public class test { // 全局数组 private final static String[] strDigits = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f" }; public test() { } // 返回形式为数字跟字符串 private static String byteToArrayString(byte bByte) { int iRet = bByte; // System.out.println("iRet="+iRet); if (iRet < 0) { iRet += 256; } int iD1 = iRet / 16; int iD2 = iRet % 16; return strDigits[iD1] + strDigits[iD2]; } // 返回形式只为数字 private static String byteToNum(byte bByte) { int iRet = bByte; System.out.println("iRet1=" + iRet); if (iRet < 0) { iRet += 256; } return String.valueOf(iRet); } // 转换字节数组为16进制字串 private static String byteToString(byte[] bByte) { StringBuffer sBuffer = new StringBuffer(); for (int i = 0; i < bByte.length; i++) { sBuffer.append(byteToArrayString(bByte[i])); } return sBuffer.toString(); } public static String GetMD5Code(String strObj) { String resultString = null; try { resultString = new String(strObj); MessageDigest md = MessageDigest.getInstance("MD5"); // md.digest() 该函数返回值为存放哈希值结果的byte数组 resultString = byteToString(md.digest(strObj.getBytes())); } catch (NoSuchAlgorithmException ex) { ex.printStackTrace(); } return resultString; } public static void main(String[] args) { test getMD5 = new test(); System.out.println(getMD5.GetMD5Code("123456").toUpperCase()); }}
0 0
- MD5 32位大写
- MD5加密32位大写
- 用JAVA编写MD5大写32位加密
- MD5 32位 小写加密和大写加密
- MD5 32位 小写加密和大写加密
- MD5加密32大写
- ASP 常用MD5加密程序(16位、32位、小写、大写)
- MD5 32位加密
- MD5加码-32位
- MD5 32位加密
- MD5 32位加密算法
- md5加密32位
- MD5 32位加密
- 32位MD5算法
- MD5 32位加密
- md5 32位加密
- MD5 32位 摘要
- MD5 32位加密
- 在maven Repository中添加自定义的jar包
- 【Ubuntu】linux Ubuntu使用Eclipse菜单栏不见了解决方法
- uva 10336
- 自己总结安装svn插件集成myeclipse2014的两种方式
- JVM GC算法 CMS 详解(转)
- MD5 32位大写
- ES6学习5(对象的拓展)
- PostgreSQL外键
- HTML5快速上手之1:与表头有关的基本指令
- linux下vim的使用
- 一.C++学习笔记-友元
- Eclispe 打开Eclispe 出现Error when loading the SDK
- mysql中innodb和myisam的区别
- 开博第一天