Results 1 to 2 of 2
  1. #1
    IYIaster is offline Member
    Join Date
    Jul 2009
    Posts
    46
    Rep Power
    0

    Default Getting md5sum from a cd.

    I'm trying to figure out how to get the md5sum of a cd/dvd in Java. This is what I'm doing to get the md5sum of the iso & it works great but, what do I need to change to get the md5sum of the cd so I can compare them.

    Java Code:
         public static byte[] createChecksum(String filename) throws
           Exception
       {
         InputStream fis =  new FileInputStream(filename);
    
         byte[] buffer = new byte[1024];
         MessageDigest complete = MessageDigest.getInstance("MD5");
         int numRead;
         do {
          numRead = fis.read(buffer);
          if (numRead > 0) {
            complete.update(buffer, 0, numRead);
            }
          } while (numRead != -1);
         fis.close();
         return complete.digest();
       }
    
       public static String getMD5Checksum(String filename) throws Exception {
         byte[] b = createChecksum(filename);
         String result = "";
         for (int i=0; i < b.length; i++) {
           result +=
              Integer.toString( ( b[i] & 0xff ) + 0x100, 16).substring( 1 );
          }
         return result;
       }

  2. #2
    PhHein's Avatar
    PhHein is offline Senior Member
    Join Date
    Apr 2009
    Location
    Germany
    Posts
    1,430
    Rep Power
    6

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •