rendered paste body/** * (c) 2007 David Bombe Roden <bombe@pterodactylus.net> */package de.ina.hddvdmd5;import java.io.ByteArrayOutputStream;import java.io.File;import java.io.FileInputStream;import java.io.FileNotFoundException;import java.io.FileOutputStream;import java.io.FileWriter;import java.io.IOException;import java.security.MessageDigest;import java.security.NoSuchAlgorithmException;import java.util.Arrays;import de.ina.util.io.StreamCopier;import de.ina.util.number.Hex;/** * @author <a href="bombe@pterodactylus.net">David Bombe Roden</a> * @version $Id$ */public class HDDVDMD5 { private static final String progressFile = "progress.dat"; private static final String resultFile = "result.dat"; private static final byte[] key = { (byte) 0x09, (byte) 0xF9, (byte) 0x11, (byte) 0x02, (byte) 0x9D, (byte) 0x74, (byte) 0xE3, (byte) 0x5B, (byte) 0xD8, (byte) 0x41, (byte) 0x56, (byte) 0xC5, (byte) 0x63, (byte) 0x56, (byte) 0x88, (byte) 0xC0 }; public static void main(String[] args) throws NoSuchAlgorithmException { new HDDVDMD5().start(); } private HDDVDMD5() { } public void start() throws NoSuchAlgorithmException { Progress currentProgress = getProgress(progressFile).getNext(); int count = 0; MessageDigest md5Digest = MessageDigest.getInstance("MD5"); while (true) { byte[] data = currentProgress.getData(); md5Digest.reset(); byte[] digest = md5Digest.digest(data); if (Arrays.equals(digest, key)) { System.out.println("found " + Hex.toHex(data)); writeResult(resultFile, data); } count++; if (count == 1000000) { System.out.print("checking " + Hex.toHex(data) + "...\r"); count = 0; writeProgress(progressFile, currentProgress); } currentProgress = currentProgress.getNext(); } } private Progress getProgress(String filename) { File progressFile = new File(filename); if (progressFile.exists()) { try { FileInputStream progressInputStream = new FileInputStream(progressFile); ByteArrayOutputStream progressOutputStream = new ByteArrayOutputStream((int) progressFile.length()); StreamCopier.copy(progressInputStream, progressOutputStream); progressOutputStream.close(); progressInputStream.close(); return new Progress(progressOutputStream.toByteArray()); } catch (FileNotFoundException e) { } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } return new Progress(new byte[0]); } private void writeProgress(String filename, Progress progress) { File progressFile = new File(filename); try { FileOutputStream progressOutputStream = new FileOutputStream(progressFile); progressOutputStream.write(progress.getData()); progressOutputStream.close(); } catch (FileNotFoundException e) { } catch (IOException e) { } } private void writeResult(String filename, byte[] data) { File resultFile = new File(filename); FileWriter fileWriter; try { fileWriter = new FileWriter(resultFile, true); fileWriter.write("Result: " + Hex.toHex(data) + "\n"); fileWriter.close(); } catch (IOException e) { } } private static class Progress { private byte[] data; public Progress(byte[] data) { this.data = data; } public byte[] getData() { return data; } public Progress getNext() { byte[] newData = new byte[data.length]; System.arraycopy(data, 0, newData, 0, data.length); boolean dontExpand = false; for (int index = 0; index < data.length; index++) { newData[index]++; if (newData[index] != 0) { dontExpand = true; break; } } if (!dontExpand) { newData = new byte[data.length + 1]; Arrays.fill(newData, (byte) 0xff); newData[data.length] = 0; } return new Progress(newData); } }}