2009-02-09 15:56:20 -05:00
|
|
|
|
2009-05-02 19:34:04 -04:00
|
|
|
package net.sourceforge.filebot.hash;
|
2009-02-09 15:56:20 -05:00
|
|
|
|
|
|
|
|
|
|
|
import java.util.zip.CRC32;
|
|
|
|
|
2009-08-10 07:46:24 -04:00
|
|
|
import net.sourceforge.filebot.MediaTypes;
|
2014-04-01 08:36:34 -04:00
|
|
|
import net.sourceforge.filebot.util.FileUtilities.ExtensionFileFilter;
|
2009-08-10 07:46:24 -04:00
|
|
|
|
2009-02-09 15:56:20 -05:00
|
|
|
|
2009-05-02 19:34:04 -04:00
|
|
|
public enum HashType {
|
2009-02-09 15:56:20 -05:00
|
|
|
|
2009-02-15 07:20:43 -05:00
|
|
|
SFV {
|
2009-02-09 15:56:20 -05:00
|
|
|
|
|
|
|
@Override
|
2009-02-15 07:20:43 -05:00
|
|
|
public Hash newHash() {
|
2009-02-09 15:56:20 -05:00
|
|
|
return new ChecksumHash(new CRC32());
|
|
|
|
}
|
2009-02-15 07:20:43 -05:00
|
|
|
|
2012-09-26 12:09:00 -04:00
|
|
|
|
2009-02-15 07:20:43 -05:00
|
|
|
@Override
|
2009-05-16 16:16:13 -04:00
|
|
|
public VerificationFormat getFormat() {
|
|
|
|
// e.g folder/file.txt 970E4EF1
|
|
|
|
return new SfvFormat();
|
2009-02-15 07:20:43 -05:00
|
|
|
}
|
|
|
|
|
2012-09-26 12:09:00 -04:00
|
|
|
|
2009-08-10 07:46:24 -04:00
|
|
|
@Override
|
|
|
|
public ExtensionFileFilter getFilter() {
|
|
|
|
return MediaTypes.getDefaultFilter("verification/sfv");
|
|
|
|
}
|
|
|
|
|
2009-02-09 15:56:20 -05:00
|
|
|
},
|
2009-02-15 07:20:43 -05:00
|
|
|
|
2009-02-09 15:56:20 -05:00
|
|
|
MD5 {
|
|
|
|
|
|
|
|
@Override
|
2009-02-15 07:20:43 -05:00
|
|
|
public Hash newHash() {
|
2009-02-09 15:56:20 -05:00
|
|
|
return new MessageDigestHash("MD5");
|
|
|
|
}
|
2009-04-06 16:58:27 -04:00
|
|
|
|
2012-09-26 12:09:00 -04:00
|
|
|
|
2009-04-06 16:58:27 -04:00
|
|
|
@Override
|
2009-05-16 16:16:13 -04:00
|
|
|
public VerificationFormat getFormat() {
|
2009-04-06 16:58:27 -04:00
|
|
|
// e.g. 50e85fe18e17e3616774637a82968f4c *folder/file.txt
|
2009-05-16 16:16:13 -04:00
|
|
|
return new VerificationFormat();
|
2009-04-06 16:58:27 -04:00
|
|
|
}
|
2009-05-16 16:16:13 -04:00
|
|
|
|
2012-09-26 12:09:00 -04:00
|
|
|
|
2009-08-10 07:46:24 -04:00
|
|
|
@Override
|
|
|
|
public ExtensionFileFilter getFilter() {
|
|
|
|
return MediaTypes.getDefaultFilter("verification/md5sum");
|
|
|
|
}
|
|
|
|
|
2009-02-09 15:56:20 -05:00
|
|
|
},
|
2009-02-15 07:20:43 -05:00
|
|
|
|
2009-02-09 15:56:20 -05:00
|
|
|
SHA1 {
|
|
|
|
|
|
|
|
@Override
|
2009-02-15 07:20:43 -05:00
|
|
|
public Hash newHash() {
|
2009-02-09 15:56:20 -05:00
|
|
|
return new MessageDigestHash("SHA-1");
|
|
|
|
}
|
2009-02-15 07:20:43 -05:00
|
|
|
|
2012-09-26 12:09:00 -04:00
|
|
|
|
2009-04-06 16:58:27 -04:00
|
|
|
@Override
|
2009-05-16 16:16:13 -04:00
|
|
|
public VerificationFormat getFormat() {
|
2009-04-06 16:58:27 -04:00
|
|
|
// e.g 1a02a7c1e9ac91346d08829d5037b240f42ded07 ?SHA1*folder/file.txt
|
2009-05-16 16:16:13 -04:00
|
|
|
return new VerificationFormat("SHA1");
|
2009-04-06 16:58:27 -04:00
|
|
|
}
|
|
|
|
|
2012-09-26 12:09:00 -04:00
|
|
|
|
2009-08-10 07:46:24 -04:00
|
|
|
@Override
|
|
|
|
public ExtensionFileFilter getFilter() {
|
|
|
|
return MediaTypes.getDefaultFilter("verification/sha1sum");
|
|
|
|
}
|
|
|
|
|
2012-09-26 12:09:00 -04:00
|
|
|
|
2009-02-15 07:20:43 -05:00
|
|
|
@Override
|
|
|
|
public String toString() {
|
|
|
|
return "SHA-1";
|
|
|
|
}
|
2009-05-16 16:16:13 -04:00
|
|
|
|
2012-09-26 12:09:00 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
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";
|
|
|
|
}
|
2009-02-09 15:56:20 -05:00
|
|
|
};
|
|
|
|
|
2009-02-15 07:20:43 -05:00
|
|
|
public abstract Hash newHash();
|
|
|
|
|
2012-09-26 12:09:00 -04:00
|
|
|
|
2009-05-16 16:16:13 -04:00
|
|
|
public abstract VerificationFormat getFormat();
|
2009-02-15 07:20:43 -05:00
|
|
|
|
2012-09-26 12:09:00 -04:00
|
|
|
|
2009-08-10 07:46:24 -04:00
|
|
|
public abstract ExtensionFileFilter getFilter();
|
2009-07-10 14:47:56 -04:00
|
|
|
|
2009-02-09 15:56:20 -05:00
|
|
|
}
|