+ support SHA-256 checksums

This commit is contained in:
Reinhard Pointner 2014-07-22 07:13:35 +00:00
parent 0415ceb37a
commit c0a59b3356
2 changed files with 54 additions and 40 deletions

View File

@ -1,119 +1,129 @@
package net.filebot.hash;
import java.util.zip.CRC32;
import net.filebot.MediaTypes;
import net.filebot.util.FileUtilities.ExtensionFileFilter;
public enum HashType {
SFV {
@Override
public Hash newHash() {
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");
}
},
MD5 {
@Override
public Hash newHash() {
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");
}
},
SHA1 {
@Override
public Hash newHash() {
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";
}
},
SHA256 {
@Override
public Hash newHash() {
return new MessageDigestHash("SHA-256");
}
@Override
public VerificationFormat getFormat() {
// e.g 1a02a7c1e9ac91346d08829d5037b240f42ded07 ?SHA1*folder/file.txt
return new VerificationFormat("SHA256");
}
@Override
public ExtensionFileFilter getFilter() {
return MediaTypes.getDefaultFilter("verification/sha256sum");
}
@Override
public String toString() {
return "SHA-2";
}
},
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

@ -25,6 +25,10 @@
<extension>sha1</extension>
<extension>sha</extension>
</type>
<type name="verification/sha256sum">
<extension>sha256</extension>
<extension>sha2</extension>
</type>
<type name="verification/ed2k">
<extension>ed2k</extension>
</type>