熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> Java編程 >> Java核心技術 >> 正文

java中使用MD5對數據密碼加密

2022-06-13   來源: Java核心技術 

  public class MD {

  public static String compute(String inStr) {

  try {

  MessageDigest md = MessageDigestgetInstance(MD);

  byte[] byteArray = inStrgetBytes(UTF);

  byte[] mdBytes = mddigest(byteArray);

  StringBuffer hexValue = new StringBuffer();

  for (int i = ; i < mdByteslength; i++) {

  int val = ((int) mdBytes[i]) & xff;

  if (val < ) {

  hexValueappend();

  }

  hexValueappend(IntegertoHexString(val));

  }

  return hexValuetoString();

  } catch (Exception e) {

  return ;

  }

  }


From:http://tw.wingwit.com/Article/program/Java/hx/201311/27097.html
    推薦文章
    Copyright © 2005-2022 電腦知識網 Computer Knowledge   All rights reserved.