[Home] [Kuri] [Sysad] [Internet?] [Blog] [Java] [Windows] [Download] [Profile] [Flash] [+] |
import java.security.MessageDigest; import java.io.FileInputStream; public class md5 { public static void main(String a[]) { try { MessageDigest md = MessageDigest.getInstance("MD5"); for(int i=0; i<a.length; i++) { FileInputStream in = new FileInputStream(a[i]); byte[] dat = new byte[256]; while(true) { int len = in.read(dat); if(len < 0) break; md.update(dat, 0, len); } in.close(); byte[] ddata = md.digest(); System.out.print("MD5 (" + a[i] + ") = "); for(int j=0; j<ddata.length; j++) { int r = (ddata[j] >= 0) ? ddata[j]:(256+ddata[j]); if(r < 0x10) { System.out.print("0"); } System.out.print(Integer.toString(r, 16)); } System.out.println(); } } catch (Exception e) { e.printStackTrace(); } } } |
[Home] [Kuri] [Sysad] [Internet?] [Blog] [Java] [Windows] [Download] [Profile] [Flash] [-] | |
usu@usupi.org | Last modified : Wed Jun 6 14:34:35 2001 |