Example #1
0
  @Test
  public void testPartHashSet() {
    String fileName = "linux-2.6.30.5.tar.bz2";
    long fileSize = 59427252;
    FileHash hash = new FileHash("5DAB0CDD691CECB21A23A8898A2513C7");

    PartHashSet hash_set = new PartHashSet(hash);
    hash_set.add(Convert.hexStringToByte("EB6F7A0CFEF22C907FF74658DF49CD31"));
    hash_set.add(Convert.hexStringToByte("C14D7F7AFCF68DD05CDEE7E35781E7B9"));
    hash_set.add(Convert.hexStringToByte("F9F70AAA59654CC30F8F55AFADBBDD40"));
    hash_set.add(Convert.hexStringToByte("46CE37AEBA15FA317DD0B0C5F5352793"));
    hash_set.add(Convert.hexStringToByte("7303D193268487C43BEED24ED38FFF96"));
    hash_set.add(Convert.hexStringToByte("6995A66BEF1E15EA146042D93B799A05"));
    hash_set.add(Convert.hexStringToByte("BCF58FF2037ED072C38F7FF394E422F5"));
    String root_hash = "JM3OTKN7KCPQDYU66JLTEVN7EVDV3627";

    String str =
        "ed2k://|file|linux-2.6.30.5.tar.bz2|59427252|5DAB0CDD691CECB21A23A8898A2513C7|p=EB6F7A0CFEF22C907FF74658DF49CD31:C14D7F7AFCF68DD05CDEE7E35781E7B9:F9F70AAA59654CC30F8F55AFADBBDD40:46CE37AEBA15FA317DD0B0C5F5352793:7303D193268487C43BEED24ED38FFF96:6995A66BEF1E15EA146042D93B799A05:BCF58FF2037ED072C38F7FF394E422F5|h=JM3OTKN7KCPQDYU66JLTEVN7EVDV3627|/";
    ED2KFileLink link = null;
    try {
      link = new ED2KFileLink(str);
    } catch (ED2KLinkMalformedException e) {
      fail(e + "");
    }

    assertEquals(fileName, link.getFileName());
    assertEquals(fileSize, link.getFileSize());
    assertEquals(hash, link.getFileHash());
    assertEquals(hash_set, link.getPartHashSet());
    assertEquals(root_hash, link.getRootHash());
  }
Example #2
0
  public FileHash(String inputString) {

    inputString = inputString.toUpperCase();

    fileHash = new byte[16];

    for (int i = 0; i < fileHash.length; i++)
      fileHash[i] =
          Convert.hexToByte(inputString.charAt(i * 2) + "" + inputString.charAt(i * 2 + 1));
  }
Example #3
0
 public String getAsString() {
   return Convert.byteToHexString(fileHash);
 }