+ added ed2k hash support to SFV panel (special thanks to thraash)

This commit is contained in:
Reinhard Pointner 2012-09-26 16:09:00 +00:00
parent cc5aec8374
commit 639fc97b51
6 changed files with 81 additions and 9 deletions

View File

@ -135,6 +135,12 @@
<include name="com/ibm/icu/**" />
</zipfileset>
<zipfileset src="${dir.lib}/jacksum.jar">
<include name="jonelo/jacksum/adapt/**" />
<include name="jonelo/jacksum/algorithm/**" />
<include name="jonelo/sugar/util/**" />
</zipfileset>
<zipfileset src="${dir.lib}/sublight-ws.jar">
<include name="net/sublight/webservice/**" />
</zipfileset>

View File

@ -46,6 +46,7 @@
<jar href="sublight-ws.jar" download="eager" />
<jar href="json-simple.jar" download="lazy" />
<jar href="junrar-custom.jar" download="lazy" />
<jar href="jacksum.jar" download="lazy" />
<jar href="nekohtml.jar" download="lazy" part="scraper" />
<jar href="xercesImpl.jar" download="lazy" part="scraper" />
<jar href="mediainfo.jar" download="lazy" part="native" />

BIN
lib/jacksum.jar Normal file

Binary file not shown.

View File

@ -0,0 +1,36 @@
package net.sourceforge.filebot.hash;
import java.math.BigInteger;
import java.security.NoSuchAlgorithmException;
import jonelo.jacksum.algorithm.Edonkey;
public class Ed2kHash implements Hash {
private final Edonkey ed2k;
public Ed2kHash() {
try {
this.ed2k = new Edonkey();
} catch (NoSuchAlgorithmException e) {
throw new RuntimeException(e);
}
}
@Override
public void update(byte[] bytes, int off, int len) {
ed2k.update(bytes, off, len);
}
@Override
public String digest() {
return String.format("%0" + (ed2k.getByteArray().length * 2) + "x", new BigInteger(1, ed2k.getByteArray()));
}
}

View File

@ -17,14 +17,14 @@ public enum HashType {
return new ChecksumHash(new CRC32());
}
@Override
public VerificationFormat getFormat() {
// e.g folder/file.txt 970E4EF1
return new SfvFormat();
}
@Override
public ExtensionFileFilter getFilter() {
return MediaTypes.getDefaultFilter("verification/sfv");
@ -39,14 +39,14 @@ public enum HashType {
return new MessageDigestHash("MD5");
}
@Override
public VerificationFormat getFormat() {
// e.g. 50e85fe18e17e3616774637a82968f4c *folder/file.txt
return new VerificationFormat();
}
@Override
public ExtensionFileFilter getFilter() {
return MediaTypes.getDefaultFilter("verification/md5sum");
@ -61,33 +61,59 @@ public enum HashType {
return new MessageDigestHash("SHA-1");
}
@Override
public VerificationFormat getFormat() {
// e.g 1a02a7c1e9ac91346d08829d5037b240f42ded07 ?SHA1*folder/file.txt
return new VerificationFormat("SHA1");
}
@Override
public ExtensionFileFilter getFilter() {
return MediaTypes.getDefaultFilter("verification/sha1sum");
}
@Override
public String toString() {
return "SHA-1";
}
},
ED2K {
@Override
public Hash newHash() {
return new Ed2kHash();
}
@Override
public VerificationFormat getFormat() {
return new VerificationFormat();
}
@Override
public ExtensionFileFilter getFilter() {
return MediaTypes.getDefaultFilter("verification/ed2k");
}
@Override
public String toString() {
return "ED2K";
}
};
public abstract Hash newHash();
public abstract VerificationFormat getFormat();
public abstract ExtensionFileFilter getFilter();
}

View File

@ -24,6 +24,9 @@
<extension>sha1</extension>
<extension>sha</extension>
</type>
<type name="verification/ed2k">
<extension>ed2k</extension>
</type>
<!-- Archives -->
<type name="archive/zip">