mysql - Java file hash for identifying identical files -


i hash of files (mostly video files) independent of external properties such path , file name. i'll needing store hash in database , compare file hash find identical files.

public byte[] digestfile( file f ){   try {     messagedigest messagedigest = messagedigest.getinstance("sha-1");     fileinputstream fis = new fileinputstream( f );     byte[] buffer = new byte[1024];     int read = -1;     while ((read = fis.read(buffer)) != -1) {       messagedigest.digest(buffer, 0, read);     }     return messagedigest.digest();   } catch (variousexceptions e) {     //handle   } } 

Comments