public static String GenerateHash(String url, Request request, boolean getRequest) { int start = HASH_SIZE * request.getAccessIndex(); int end = start + HASH_SIZE; DaapHost host = request.getHost(); calculateStaticHash(host); // System.out.println("Creating hash, reqid is " + reqid); if (host.getDaapVersion() >= DaapHost.ITUNES_45) { // System.out.println("Generating 4.5 Hash"); // nmd = new MD5(); // nmd.Update(url.getBytes()); // nmd.Update(appleCopyright.getBytes()); // nmd.Update(calcHash.substring(start, end).getBytes()); // // if (getRequest) { // nmd.Update((new Integer(host.getThisRequestNumber())).toString().getBytes()); // // System.out.println("Adding this compontent"); // // } // return DigestToString(nmd.Final()); return ""; } else { md.update(url.getBytes()); md.update(appleCopyright.getBytes()); md.update(calcHash.substring(start, end).getBytes()); return DigestToString(md.digest()); } }
private static synchronized void calculateStaticHash(DaapHost host) { if (staticCalculated && (host.getDaapVersion() == hashVersion)) return; calcHash = ""; // System.out.println("Regenerating static hash"); if (host.getDaapVersion() >= DaapHost.ITUNES_45) calculate45StaticHash(); else calculate40StaticHash(); hashVersion = host.getDaapVersion(); }