From c0a59b3356cb0ab5d2ce00fa0ffeef66409cd8c2 Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Tue, 22 Jul 2014 07:13:35 +0000 Subject: [PATCH] + support SHA-256 checksums --- source/net/filebot/hash/HashType.java | 90 +++++++++++++++------------ source/net/filebot/media.types | 4 ++ 2 files changed, 54 insertions(+), 40 deletions(-) diff --git a/source/net/filebot/hash/HashType.java b/source/net/filebot/hash/HashType.java index d8c2f208..ddcfd19f 100644 --- a/source/net/filebot/hash/HashType.java +++ b/source/net/filebot/hash/HashType.java @@ -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(); - + } diff --git a/source/net/filebot/media.types b/source/net/filebot/media.types index a736744e..25f2dfc6 100644 --- a/source/net/filebot/media.types +++ b/source/net/filebot/media.types @@ -25,6 +25,10 @@ sha1 sha + + sha256 + sha2 + ed2k