当前所在位置:珠峰网资料 >> 计算机 >> 计算机等级考试 >> 正文
计算机二级辅导:java中使用MD5对数据密码加密
发布时间:2010/3/14 18:41:17 来源:城市学习网 编辑:MOON
  public class MD5 {
  public static String compute(String inStr) {
  try {
  MessageDigest md5 = MessageDigest.getInstance("MD5");
  byte byteArray = inStr.getBytes("UTF-8");
  byte md5Bytes = md5.digest(byteArray);
  StringBuffer hexValue = new StringBuffer(32);
  for (int i = 0; i md5Bytes.length; i++) {
  int val = ((int) md5Bytes[i]) & 0xff;
  if (val 16) {
  hexValue.append("0");
  }
  hexValue.append(Integer.toHexString(val));
  }
  return hexValue.toString();
  } catch (Exception e) {
  return "";
  }
  }
  :
广告合作:400-664-0084 全国热线:400-664-0084
Copyright 2010 - 2017 www.my8848.com 珠峰网 粤ICP备15066211号
珠峰网 版权所有 All Rights Reserved