package sf_md;
import javaio*;
import javasecurity*;
//import javautil*;
//import javasecurityinterfaces*;
public class MD_算法 {
private String inStr;
private MessageDigest mad;
public MD_算法(String inStr){
thisinStr=inStr;
try{
thismad=MessageDigestgetInstance(MD);
}
catch(Exception e){
Systemoutprintln(etoString());
eprintStackTrace();
}
}
public String compute(){
char[] charArray=thisinStrtoCharArray();
byte[] byteArray=new byte[charArraylength];
for(int i=;i<charArraylength;i++)
byteArray[i]=(byte)charArray[i];
byte[] mdBytes=thismaddigest(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();
}
public static void main(String[] args) {
String string=null;
try{
Systemoutprintln(请输入要加密的数据:);
BufferedReader br=new BufferedReader(new InputStreamReader(Systemin));
string=brreadLine();
}
catch(IOException e){
Systemoutprintln(e);
}
MD_算法 md =new MD_算法(string);
String postString =pute();
Systemoutprintln(加密后的数据:+postString);
}
}