diff --git a/Adler32Context.cs b/Adler32Context.cs
index f6fa9db..083ae31 100644
--- a/Adler32Context.cs
+++ b/Adler32Context.cs
@@ -39,7 +39,7 @@ namespace DiscImageChef.Checksums
///
/// Implements the Adler-32 algorithm
///
- public class Adler32Context
+ public class Adler32Context : IChecksum
{
const ushort ADLER_MODULE = 65521;
ushort sum1, sum2;
diff --git a/CRC16Context.cs b/CRC16Context.cs
index 7bcb215..ec65593 100644
--- a/CRC16Context.cs
+++ b/CRC16Context.cs
@@ -39,7 +39,7 @@ namespace DiscImageChef.Checksums
///
/// Implements a CRC16-CCITT algorithm
///
- public class Crc16Context
+ public class Crc16Context : IChecksum
{
const ushort CRC16_POLY = 0xA001;
const ushort CRC16_SEED = 0x0000;
diff --git a/CRC32Context.cs b/CRC32Context.cs
index 97680b6..e231996 100644
--- a/CRC32Context.cs
+++ b/CRC32Context.cs
@@ -39,7 +39,7 @@ namespace DiscImageChef.Checksums
///
/// Implements a CRC32 algorithm
///
- public class Crc32Context
+ public class Crc32Context : IChecksum
{
const uint CRC32_POLY = 0xEDB88320;
const uint CRC32_SEED = 0xFFFFFFFF;
diff --git a/CRC64Context.cs b/CRC64Context.cs
index 35f3be4..b1bc62b 100644
--- a/CRC64Context.cs
+++ b/CRC64Context.cs
@@ -39,7 +39,7 @@ namespace DiscImageChef.Checksums
///
/// Implements a CRC64 (ECMA) algorithm
///
- public class Crc64Context
+ public class Crc64Context : IChecksum
{
const ulong CRC64_POLY = 0xC96C5795D7870F42;
const ulong CRC64_SEED = 0xFFFFFFFFFFFFFFFF;
diff --git a/DiscImageChef.Checksums.csproj b/DiscImageChef.Checksums.csproj
index 9a5bfdd..bc35cb3 100644
--- a/DiscImageChef.Checksums.csproj
+++ b/DiscImageChef.Checksums.csproj
@@ -1,4 +1,4 @@
-
+
Debug
@@ -34,6 +34,7 @@
+
diff --git a/FletcherContext.cs b/FletcherContext.cs
index da63771..a79c739 100644
--- a/FletcherContext.cs
+++ b/FletcherContext.cs
@@ -31,14 +31,14 @@
// ****************************************************************************/
// Disabled because the speed is abnormally slow
-/*
+
using System;
using System.IO;
using System.Text;
namespace DiscImageChef.Checksums
{
- public class Fletcher32Context
+ public class Fletcher32Context : IChecksum
{
bool inodd;
byte oddValue;
@@ -423,4 +423,4 @@ namespace DiscImageChef.Checksums
return Data(data, (uint)data.Length, out hash);
}
}
-}*/
\ No newline at end of file
+}
\ No newline at end of file
diff --git a/IChecksum.cs b/IChecksum.cs
new file mode 100644
index 0000000..a29a96b
--- /dev/null
+++ b/IChecksum.cs
@@ -0,0 +1,65 @@
+// /***************************************************************************
+// The Disc Image Chef
+// ----------------------------------------------------------------------------
+//
+// Filename : IChecksum.cs
+// Author(s) : Natalia Portillo
+//
+// Component : Checksums.
+//
+// --[ Description ] ----------------------------------------------------------
+//
+// Provides an interface for implementing checksums and hashes.
+//
+// --[ License ] --------------------------------------------------------------
+//
+// This library is free software; you can redistribute it and/or modify
+// it under the terms of the GNU Lesser General Public License as
+// published by the Free Software Foundation; either version 2.1 of the
+// License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, see .
+//
+// ----------------------------------------------------------------------------
+// Copyright © 2011-2018 Natalia Portillo
+// ****************************************************************************/
+
+namespace DiscImageChef.Checksums
+{
+ public interface IChecksum
+ {
+ ///
+ /// Initializes the algorithm
+ ///
+ void Init();
+
+ ///
+ /// Updates the hash with data.
+ ///
+ /// Data buffer.
+ /// Length of buffer to hash.
+ void Update(byte[] data, uint len);
+
+ ///
+ /// Updates the hash with data.
+ ///
+ /// Data buffer.
+ void Update(byte[] data);
+
+ ///
+ /// Returns a byte array of the hash value.
+ ///
+ byte[] Final();
+
+ ///
+ /// Returns a hexadecimal representation of the hash value.
+ ///
+ string End();
+ }
+}
\ No newline at end of file
diff --git a/MD5Context.cs b/MD5Context.cs
index 8e3bc3f..6fd0dc2 100644
--- a/MD5Context.cs
+++ b/MD5Context.cs
@@ -39,7 +39,7 @@ namespace DiscImageChef.Checksums
///
/// Wraps up .NET MD5 implementation to a Init(), Update(), Final() context.
///
- public class Md5Context
+ public class Md5Context : IChecksum
{
MD5 md5Provider;
diff --git a/RIPEMD160Context.cs b/RIPEMD160Context.cs
index c9bca19..120f2cb 100644
--- a/RIPEMD160Context.cs
+++ b/RIPEMD160Context.cs
@@ -39,7 +39,7 @@ namespace DiscImageChef.Checksums
///
/// Wraps up .NET RIPEMD160 implementation to a Init(), Update(), Final() context.
///
- public class Ripemd160Context
+ public class Ripemd160Context : IChecksum
{
RIPEMD160 ripemd160Provider;
diff --git a/SHA1Context.cs b/SHA1Context.cs
index 8de3a5d..f62887a 100644
--- a/SHA1Context.cs
+++ b/SHA1Context.cs
@@ -39,7 +39,7 @@ namespace DiscImageChef.Checksums
///
/// Wraps up .NET SHA1 implementation to a Init(), Update(), Final() context.
///
- public class Sha1Context
+ public class Sha1Context : IChecksum
{
SHA1 sha1Provider;
diff --git a/SHA256Context.cs b/SHA256Context.cs
index 3a062e3..43e1073 100644
--- a/SHA256Context.cs
+++ b/SHA256Context.cs
@@ -39,7 +39,7 @@ namespace DiscImageChef.Checksums
///
/// Wraps up .NET SHA256 implementation to a Init(), Update(), Final() context.
///
- public class Sha256Context
+ public class Sha256Context : IChecksum
{
SHA256 sha256Provider;
diff --git a/SHA384Context.cs b/SHA384Context.cs
index 225ac75..1fd534c 100644
--- a/SHA384Context.cs
+++ b/SHA384Context.cs
@@ -39,7 +39,7 @@ namespace DiscImageChef.Checksums
///
/// Wraps up .NET SHA384 implementation to a Init(), Update(), Final() context.
///
- public class Sha384Context
+ public class Sha384Context : IChecksum
{
SHA384 sha384Provider;
diff --git a/SHA512Context.cs b/SHA512Context.cs
index 94b3bca..5beb4cc 100644
--- a/SHA512Context.cs
+++ b/SHA512Context.cs
@@ -39,7 +39,7 @@ namespace DiscImageChef.Checksums
///
/// Wraps up .NET SHA512 implementation to a Init(), Update(), Final() context.
///
- public class Sha512Context
+ public class Sha512Context : IChecksum
{
SHA512 sha512Provider;
diff --git a/SpamSumContext.cs b/SpamSumContext.cs
index 30a1c1f..1487832 100644
--- a/SpamSumContext.cs
+++ b/SpamSumContext.cs
@@ -47,7 +47,7 @@ namespace DiscImageChef.Checksums
///
/// Implements the SpamSum fuzzy hashing algorithm.
///
- public class SpamSumContext
+ public class SpamSumContext : IChecksum
{
const uint ROLLING_WINDOW = 7;
const uint MIN_BLOCKSIZE = 3;