日期:2014-05-20 浏览次数:20821 次
import java.security.MessageDigest;这是我的全部代码,我想以往一样,run as -->java application,结果说could not find the main
import java.security.NoSuchAlgorithmException;
public class MD5Test {
/**
* @param args
*/
public static void main(String[] args) {
String s = "123456";
char hexDigits[] = {
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
'a', 'b', 'c', 'd', 'e', 'f'
};
char str[];
byte strTemp[] = s.getBytes();
try {
MessageDigest mdTemp = MessageDigest.getInstance("MD5");
mdTemp.update(strTemp);
byte md[] = mdTemp.digest();
int j = md.length;
str = new char[j * 2];
int k = 0;
for (int i = 0; i < j; i++){
byte byte0 = md[i];
str[k++] = hexDigits[byte0 >>> 4 & 0xf];
str[k++] = hexDigits[byte0 & 0xf];
}
System.out.println(str);
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}
}
}