You can create MD5 hashes for any arbitrary file, regardless of file type. The hash simply takes any stream of bytes and does not interpret its value at all. That way, you can use the examples you found for .txt files and apply them to .zip files.
, .zip, , MD5 .zip - , - -. .
, , MD5, . , , , , , zipped .
( ):
MD5 , MD5 . " ", , . ZipInputStream . :
InputStream theFile = new FileInputStream("example.zip");
ZipInputStream stream = new ZipInputStream(theFile);
try
{
ZipEntry entry;
while((entry = stream.getNextEntry()) != null)
{
MessageDigest md = MessageDigest.getInstance("MD5");
DigestInputStream dis = new DigestInputStream(stream, md);
byte[] buffer = new byte[1024];
int read = dis.read(buffer);
while (read > -1) {
read = dis.read(buffer);
}
System.out.println(entry.getName() + ": "
+ Arrays.toString(dis.getMessageDigest().digest()));
}
} finally { stream.close(); }