tl  tr
  Home | Tutorials | Articles | Videos | Products | Tools | Search
Interviews | Open Source | Tag Cloud | Follow Us | Bookmark | Contact   
 Tools and Libs > Ostermiller Utilities > MD5 Hash of File

MD5 Hash of File 

Ostermiller Java Utilities contain various components such as CSV parsing, Base64 Encoding, MD5 digest, String and Exec Helper classes. This requires the library ostermillerutils-1.08.01.jar to be in classpath. The following example shows getting MD5 hash of files and streams using MD5.getHashString() API.

File Name  :  
com/bethecoder/tutorials/ostermillerutils/MD5FileTest.java 
Author  :  Sudhakar KV
Email  :  [email protected]
   
package com.bethecoder.tutorials.ostermillerutils;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;

import com.Ostermiller.util.MD5;

public class MD5FileTest {

  /**
   @param args
   @throws IOException 
   */
  public static void main(String[] argsthrows IOException {

    String hash = MD5.getHashString(new File("C:/Test/Test.java"));
    System.out.println(hash);
    
    InputStream input = new FileInputStream("C:/Test/Test.java");
    hash = MD5.getHashString(input);
    System.out.println(hash);
  }

}
   

It gives the following output,
4ed0bc4b977ec97cfb5404c20d4b00aa
4ed0bc4b977ec97cfb5404c20d4b00aa



 
  


  
bl  br