MD5的算法和使用

时间:2015-11-13 10:15:08
【文件属性】:

文件名称:MD5的算法和使用

文件大小:2KB

文件格式:TXT

更新时间:2015-11-13 10:15:08

MD5

javaMD5 java实现MD5算法 关键词: java MD5 import java.security.*; import java.util.*; /** * */ public class MD5 { private String inStr; private MessageDigest md5; /** * Constructs the MD5 object and sets the string whose MD5 is to be computed. * * @param inStr the String whose MD5 is to be computed */ public MD5(String inStr) { this.inStr = inStr; try { this.md5 = MessageDigest.getInstance("MD5"); } catch (Exception e) { System.out.println(e.toString()); e.printStackTrace(); } } /** * Computes the MD5 fingerprint of a string. * * @return the MD5 digest of the input String */ public String compute() { // convert input String to a char[] // convert that char[] to byte[] // get the md5 digest as byte[] // bit-wise AND that byte[] with 0xff


网友评论