diff --git a/Adler32Context.cs b/Adler32Context.cs
index 4d969c545..09128e039 100644
--- a/Adler32Context.cs
+++ b/Adler32Context.cs
@@ -38,8 +38,8 @@ namespace DiscImageChef.Checksums
{
public class Adler32Context
{
- UInt16 sum1, sum2;
- const UInt16 AdlerModule = 65521;
+ ushort sum1, sum2;
+ const ushort AdlerModule = 65521;
///
/// Initializes the Adler-32 sums
@@ -78,7 +78,7 @@ namespace DiscImageChef.Checksums
///
public byte[] Final()
{
- UInt32 finalSum = (uint)((sum2 << 16) | sum1);
+ uint finalSum = (uint)((sum2 << 16) | sum1);
return BigEndianBitConverter.GetBytes(finalSum);
}
@@ -87,7 +87,7 @@ namespace DiscImageChef.Checksums
///
public string End()
{
- UInt32 finalSum = (uint)((sum2 << 16) | sum1);
+ uint finalSum = (uint)((sum2 << 16) | sum1);
StringBuilder adlerOutput = new StringBuilder();
for(int i = 0; i < BigEndianBitConverter.GetBytes(finalSum).Length; i++)
@@ -117,8 +117,8 @@ namespace DiscImageChef.Checksums
public static string File(string filename, out byte[] hash)
{
FileStream fileStream = new FileStream(filename, FileMode.Open);
- UInt16 localSum1, localSum2;
- UInt32 finalSum;
+ ushort localSum1, localSum2;
+ uint finalSum;
localSum1 = 1;
localSum2 = 0;
@@ -148,8 +148,8 @@ namespace DiscImageChef.Checksums
/// Byte array of the hash value.
public static string Data(byte[] data, uint len, out byte[] hash)
{
- UInt16 localSum1, localSum2;
- UInt32 finalSum;
+ ushort localSum1, localSum2;
+ uint finalSum;
localSum1 = 1;
localSum2 = 0;
diff --git a/CDChecksums.cs b/CDChecksums.cs
index 73e499c00..4ad090c32 100644
--- a/CDChecksums.cs
+++ b/CDChecksums.cs
@@ -40,8 +40,8 @@ namespace DiscImageChef.Checksums
{
static byte[] ECC_F_Table;
static byte[] ECC_B_Table;
- const UInt32 CDCRC32Poly = 0xD8018001;
- const UInt32 CDCRC32Seed = 0x00000000;
+ const uint CDCRC32Poly = 0xD8018001;
+ const uint CDCRC32Seed = 0x00000000;
public static bool? CheckCDSector(byte[] buffer)
{
@@ -84,9 +84,9 @@ namespace DiscImageChef.Checksums
ECC_F_Table = new byte[256];
ECC_B_Table = new byte[256];
- for(UInt32 i = 0; i < 256; i++)
+ for(uint i = 0; i < 256; i++)
{
- UInt32 j = (uint)((i << 1) ^ ((i & 0x80) == 0x80 ? 0x11D : 0));
+ uint j = (uint)((i << 1) ^ ((i & 0x80) == 0x80 ? 0x11D : 0));
ECC_F_Table[i] = (byte)j;
ECC_B_Table[i ^ j] = (byte)i;
}
@@ -95,21 +95,21 @@ namespace DiscImageChef.Checksums
static bool CheckECC(
byte[] address,
byte[] data,
- UInt32 major_count,
- UInt32 minor_count,
- UInt32 major_mult,
- UInt32 minor_inc,
+ uint major_count,
+ uint minor_count,
+ uint major_mult,
+ uint minor_inc,
byte[] ecc
)
{
- UInt32 size = major_count * minor_count;
- UInt32 major;
+ uint size = major_count * minor_count;
+ uint major;
for(major = 0; major < major_count; major++)
{
- UInt32 index = (major >> 1) * major_mult + (major & 1);
+ uint index = (major >> 1) * major_mult + (major & 1);
byte ecc_a = 0;
byte ecc_b = 0;
- UInt32 minor;
+ uint minor;
for(minor = 0; minor < minor_count; minor++)
{
byte temp;
@@ -215,11 +215,11 @@ namespace DiscImageChef.Checksums
return false;
byte[] SectorForCheck = new byte[0x810];
- UInt32 StoredEDC = BitConverter.ToUInt32(channel, 0x810);
+ uint StoredEDC = BitConverter.ToUInt32(channel, 0x810);
byte[] CalculatedEDCBytes;
Array.Copy(channel, 0, SectorForCheck, 0, 0x810);
CRC32Context.Data(SectorForCheck, 0x810, out CalculatedEDCBytes, CDCRC32Poly, CDCRC32Seed);
- UInt32 CalculatedEDC = BitConverter.ToUInt32(CalculatedEDCBytes, 0);
+ uint CalculatedEDC = BitConverter.ToUInt32(CalculatedEDCBytes, 0);
if(CalculatedEDC != StoredEDC)
{
@@ -241,11 +241,11 @@ namespace DiscImageChef.Checksums
}
byte[] SectorForCheck = new byte[0x91C];
- UInt32 StoredEDC = BitConverter.ToUInt32(channel, 0x92C);
+ uint StoredEDC = BitConverter.ToUInt32(channel, 0x92C);
byte[] CalculatedEDCBytes;
Array.Copy(channel, 0x10, SectorForCheck, 0, 0x91C);
CRC32Context.Data(SectorForCheck, 0x91C, out CalculatedEDCBytes, CDCRC32Poly, CDCRC32Seed);
- UInt32 CalculatedEDC = BitConverter.ToUInt32(CalculatedEDCBytes, 0);
+ uint CalculatedEDC = BitConverter.ToUInt32(CalculatedEDCBytes, 0);
if(CalculatedEDC != StoredEDC && StoredEDC != 0x00000000)
{
@@ -287,11 +287,11 @@ namespace DiscImageChef.Checksums
return false;
byte[] SectorForCheck = new byte[0x808];
- UInt32 StoredEDC = BitConverter.ToUInt32(channel, 0x818);
+ uint StoredEDC = BitConverter.ToUInt32(channel, 0x818);
byte[] CalculatedEDCBytes;
Array.Copy(channel, 0x10, SectorForCheck, 0, 0x808);
CRC32Context.Data(SectorForCheck, 0x808, out CalculatedEDCBytes, CDCRC32Poly, CDCRC32Seed);
- UInt32 CalculatedEDC = BitConverter.ToUInt32(CalculatedEDCBytes, 0);
+ uint CalculatedEDC = BitConverter.ToUInt32(CalculatedEDCBytes, 0);
if(CalculatedEDC != StoredEDC)
{
@@ -464,10 +464,10 @@ namespace DiscImageChef.Checksums
BigEndianBitConverter.IsLittleEndian = true;
- UInt16 QSubChannelCRC = BigEndianBitConverter.ToUInt16(QSubChannel, 10);
+ ushort QSubChannelCRC = BigEndianBitConverter.ToUInt16(QSubChannel, 10);
byte[] QSubChannelForCRC = new byte[10];
Array.Copy(QSubChannel, 0, QSubChannelForCRC, 0, 10);
- UInt16 CalculatedQCRC = CalculateCCITT_CRC16(QSubChannelForCRC);
+ ushort CalculatedQCRC = CalculateCCITT_CRC16(QSubChannelForCRC);
if(QSubChannelCRC != CalculatedQCRC)
{
@@ -477,10 +477,10 @@ namespace DiscImageChef.Checksums
if((CDTextPack1[0] & 0x80) == 0x80)
{
- UInt16 CDTextPack1CRC = BigEndianBitConverter.ToUInt16(CDTextPack1, 16);
+ ushort CDTextPack1CRC = BigEndianBitConverter.ToUInt16(CDTextPack1, 16);
byte[] CDTextPack1ForCRC = new byte[16];
Array.Copy(CDTextPack1, 0, CDTextPack1ForCRC, 0, 16);
- UInt16 CalculatedCDTP1CRC = CalculateCCITT_CRC16(CDTextPack1ForCRC);
+ ushort CalculatedCDTP1CRC = CalculateCCITT_CRC16(CDTextPack1ForCRC);
if(CDTextPack1CRC != CalculatedCDTP1CRC && CDTextPack1CRC != 0)
{
@@ -491,10 +491,10 @@ namespace DiscImageChef.Checksums
if((CDTextPack2[0] & 0x80) == 0x80)
{
- UInt16 CDTextPack2CRC = BigEndianBitConverter.ToUInt16(CDTextPack2, 16);
+ ushort CDTextPack2CRC = BigEndianBitConverter.ToUInt16(CDTextPack2, 16);
byte[] CDTextPack2ForCRC = new byte[16];
Array.Copy(CDTextPack2, 0, CDTextPack2ForCRC, 0, 16);
- UInt16 CalculatedCDTP2CRC = CalculateCCITT_CRC16(CDTextPack2ForCRC);
+ ushort CalculatedCDTP2CRC = CalculateCCITT_CRC16(CDTextPack2ForCRC);
DicConsole.DebugWriteLine("CD checksums", "Cyclic CDTP2 0x{0:X4}, Calc CDTP2 0x{1:X4}", CDTextPack2CRC, CalculatedCDTP2CRC);
if(CDTextPack2CRC != CalculatedCDTP2CRC && CDTextPack2CRC != 0)
@@ -506,10 +506,10 @@ namespace DiscImageChef.Checksums
if((CDTextPack3[0] & 0x80) == 0x80)
{
- UInt16 CDTextPack3CRC = BigEndianBitConverter.ToUInt16(CDTextPack3, 16);
+ ushort CDTextPack3CRC = BigEndianBitConverter.ToUInt16(CDTextPack3, 16);
byte[] CDTextPack3ForCRC = new byte[16];
Array.Copy(CDTextPack3, 0, CDTextPack3ForCRC, 0, 16);
- UInt16 CalculatedCDTP3CRC = CalculateCCITT_CRC16(CDTextPack3ForCRC);
+ ushort CalculatedCDTP3CRC = CalculateCCITT_CRC16(CDTextPack3ForCRC);
DicConsole.DebugWriteLine("CD checksums", "Cyclic CDTP3 0x{0:X4}, Calc CDTP3 0x{1:X4}", CDTextPack3CRC, CalculatedCDTP3CRC);
if(CDTextPack3CRC != CalculatedCDTP3CRC && CDTextPack3CRC != 0)
@@ -521,10 +521,10 @@ namespace DiscImageChef.Checksums
if((CDTextPack4[0] & 0x80) == 0x80)
{
- UInt16 CDTextPack4CRC = BigEndianBitConverter.ToUInt16(CDTextPack4, 16);
+ ushort CDTextPack4CRC = BigEndianBitConverter.ToUInt16(CDTextPack4, 16);
byte[] CDTextPack4ForCRC = new byte[16];
Array.Copy(CDTextPack4, 0, CDTextPack4ForCRC, 0, 16);
- UInt16 CalculatedCDTP4CRC = CalculateCCITT_CRC16(CDTextPack4ForCRC);
+ ushort CalculatedCDTP4CRC = CalculateCCITT_CRC16(CDTextPack4ForCRC);
DicConsole.DebugWriteLine("CD checksums", "Cyclic CDTP4 0x{0:X4}, Calc CDTP4 0x{1:X4}", CDTextPack4CRC, CalculatedCDTP4CRC);
if(CDTextPack4CRC != CalculatedCDTP4CRC && CDTextPack4CRC != 0)
@@ -570,12 +570,12 @@ namespace DiscImageChef.Checksums
0xfd2e, 0xed0f, 0xdd6c, 0xcd4d, 0xbdaa, 0xad8b, 0x9de8, 0x8dc9,
0x7c26, 0x6c07, 0x5c64, 0x4c45, 0x3ca2, 0x2c83, 0x1ce0, 0x0cc1,
0xef1f, 0xff3e, 0xcf5d, 0xdf7c, 0xaf9b, 0xbfba, 0x8fd9, 0x9ff8,
- 0x6e17, 0x7e36, 0x4e55, 0x5e74, 0x2e93, 0x3eb2, 0x0ed1, 0x1ef0,
+ 0x6e17, 0x7e36, 0x4e55, 0x5e74, 0x2e93, 0x3eb2, 0x0ed1, 0x1ef0
};
static ushort CalculateCCITT_CRC16(byte[] buffer)
{
- UInt16 CRC16 = 0;
+ ushort CRC16 = 0;
for(int i = 0; i < buffer.Length; i++)
{
CRC16 = (ushort)(CCITT_CRC16Table[(CRC16 >> 8) ^ buffer[i]] ^ (CRC16 << 8));
diff --git a/CRC16Context.cs b/CRC16Context.cs
index 1a8c49502..777d36144 100644
--- a/CRC16Context.cs
+++ b/CRC16Context.cs
@@ -41,11 +41,11 @@ namespace DiscImageChef.Checksums
///
public class CRC16Context
{
- const UInt16 crc16Poly = 0xA001;
- const UInt16 crc16Seed = 0x0000;
+ const ushort crc16Poly = 0xA001;
+ const ushort crc16Seed = 0x0000;
- UInt16[] table;
- UInt16 hashInt;
+ ushort[] table;
+ ushort hashInt;
///
/// Initializes the CRC16 table and seed
@@ -54,10 +54,10 @@ namespace DiscImageChef.Checksums
{
hashInt = crc16Seed;
- table = new UInt16[256];
+ table = new ushort[256];
for(int i = 0; i < 256; i++)
{
- UInt16 entry = (UInt16)i;
+ ushort entry = (ushort)i;
for(int j = 0; j < 8; j++)
if((entry & 1) == 1)
entry = (ushort)((entry >> 1) ^ crc16Poly);
@@ -133,15 +133,15 @@ namespace DiscImageChef.Checksums
public static string File(string filename, out byte[] hash)
{
FileStream fileStream = new FileStream(filename, FileMode.Open);
- UInt16[] localTable;
- UInt16 localhashInt;
+ ushort[] localTable;
+ ushort localhashInt;
localhashInt = crc16Seed;
- localTable = new UInt16[256];
+ localTable = new ushort[256];
for(int i = 0; i < 256; i++)
{
- UInt16 entry = (UInt16)i;
+ ushort entry = (ushort)i;
for(int j = 0; j < 8; j++)
if((entry & 1) == 1)
entry = (ushort)((entry >> 1) ^ crc16Poly);
@@ -185,17 +185,17 @@ namespace DiscImageChef.Checksums
/// Byte array of the hash value.
/// CRC polynomial
/// CRC seed
- public static string Data(byte[] data, uint len, out byte[] hash, UInt16 polynomial, UInt16 seed)
+ public static string Data(byte[] data, uint len, out byte[] hash, ushort polynomial, ushort seed)
{
- UInt16[] localTable;
- UInt16 localhashInt;
+ ushort[] localTable;
+ ushort localhashInt;
localhashInt = seed;
- localTable = new UInt16[256];
+ localTable = new ushort[256];
for(int i = 0; i < 256; i++)
{
- UInt16 entry = (UInt16)i;
+ ushort entry = (ushort)i;
for(int j = 0; j < 8; j++)
if((entry & 1) == 1)
entry = (ushort)((entry >> 1) ^ polynomial);
diff --git a/CRC32Context.cs b/CRC32Context.cs
index f0dbacacb..774c33576 100644
--- a/CRC32Context.cs
+++ b/CRC32Context.cs
@@ -41,11 +41,11 @@ namespace DiscImageChef.Checksums
///
public class CRC32Context
{
- const UInt32 crc32Poly = 0xEDB88320;
- const UInt32 crc32Seed = 0xFFFFFFFF;
+ const uint crc32Poly = 0xEDB88320;
+ const uint crc32Seed = 0xFFFFFFFF;
- UInt32[] table;
- UInt32 hashInt;
+ uint[] table;
+ uint hashInt;
///
/// Initializes the CRC32 table and seed
@@ -54,10 +54,10 @@ namespace DiscImageChef.Checksums
{
hashInt = crc32Seed;
- table = new UInt32[256];
+ table = new uint[256];
for(int i = 0; i < 256; i++)
{
- UInt32 entry = (UInt32)i;
+ uint entry = (uint)i;
for(int j = 0; j < 8; j++)
if((entry & 1) == 1)
entry = (entry >> 1) ^ crc32Poly;
@@ -133,15 +133,15 @@ namespace DiscImageChef.Checksums
public static string File(string filename, out byte[] hash)
{
FileStream fileStream = new FileStream(filename, FileMode.Open);
- UInt32[] localTable;
- UInt32 localhashInt;
+ uint[] localTable;
+ uint localhashInt;
localhashInt = crc32Seed;
- localTable = new UInt32[256];
+ localTable = new uint[256];
for(int i = 0; i < 256; i++)
{
- UInt32 entry = (UInt32)i;
+ uint entry = (uint)i;
for(int j = 0; j < 8; j++)
if((entry & 1) == 1)
entry = (entry >> 1) ^ crc32Poly;
@@ -185,17 +185,17 @@ namespace DiscImageChef.Checksums
/// Byte array of the hash value.
/// CRC polynomial
/// CRC seed
- public static string Data(byte[] data, uint len, out byte[] hash, UInt32 polynomial, UInt32 seed)
+ public static string Data(byte[] data, uint len, out byte[] hash, uint polynomial, uint seed)
{
- UInt32[] localTable;
- UInt32 localhashInt;
+ uint[] localTable;
+ uint localhashInt;
localhashInt = seed;
- localTable = new UInt32[256];
+ localTable = new uint[256];
for(int i = 0; i < 256; i++)
{
- UInt32 entry = (UInt32)i;
+ uint entry = (uint)i;
for(int j = 0; j < 8; j++)
if((entry & 1) == 1)
entry = (entry >> 1) ^ polynomial;
diff --git a/CRC64Context.cs b/CRC64Context.cs
index f11c6f420..84827ba3f 100644
--- a/CRC64Context.cs
+++ b/CRC64Context.cs
@@ -41,11 +41,11 @@ namespace DiscImageChef.Checksums
///
public class CRC64Context
{
- const UInt64 crc64Poly = 0xC96C5795D7870F42;
- const UInt64 crc64Seed = 0xFFFFFFFFFFFFFFFF;
+ const ulong crc64Poly = 0xC96C5795D7870F42;
+ const ulong crc64Seed = 0xFFFFFFFFFFFFFFFF;
- UInt64[] table;
- UInt64 hashInt;
+ ulong[] table;
+ ulong hashInt;
///
/// Initializes the CRC64 table and seed
@@ -54,10 +54,10 @@ namespace DiscImageChef.Checksums
{
hashInt = crc64Seed;
- table = new UInt64[256];
+ table = new ulong[256];
for(int i = 0; i < 256; i++)
{
- UInt64 entry = (UInt64)i;
+ ulong entry = (ulong)i;
for(int j = 0; j < 8; j++)
if((entry & 1) == 1)
entry = (entry >> 1) ^ crc64Poly;
@@ -133,15 +133,15 @@ namespace DiscImageChef.Checksums
public static string File(string filename, out byte[] hash)
{
FileStream fileStream = new FileStream(filename, FileMode.Open);
- UInt64[] localTable;
- UInt64 localhashInt;
+ ulong[] localTable;
+ ulong localhashInt;
localhashInt = crc64Seed;
- localTable = new UInt64[256];
+ localTable = new ulong[256];
for(int i = 0; i < 256; i++)
{
- UInt64 entry = (UInt64)i;
+ ulong entry = (ulong)i;
for(int j = 0; j < 8; j++)
if((entry & 1) == 1)
entry = (entry >> 1) ^ crc64Poly;
@@ -151,7 +151,7 @@ namespace DiscImageChef.Checksums
}
for(int i = 0; i < fileStream.Length; i++)
- localhashInt = (localhashInt >> 8) ^ localTable[(ulong)fileStream.ReadByte() ^ localhashInt & (ulong)0xff];
+ localhashInt = (localhashInt >> 8) ^ localTable[(ulong)fileStream.ReadByte() ^ localhashInt & 0xffL];
BigEndianBitConverter.IsLittleEndian = BigEndianBitConverter.IsLittleEndian;
hash = BitConverter.GetBytes(localhashInt);
@@ -185,17 +185,17 @@ namespace DiscImageChef.Checksums
/// Byte array of the hash value.
/// CRC polynomial
/// CRC seed
- public static string Data(byte[] data, uint len, out byte[] hash, UInt64 polynomial, UInt64 seed)
+ public static string Data(byte[] data, uint len, out byte[] hash, ulong polynomial, ulong seed)
{
- UInt64[] localTable;
- UInt64 localhashInt;
+ ulong[] localTable;
+ ulong localhashInt;
localhashInt = seed;
- localTable = new UInt64[256];
+ localTable = new ulong[256];
for(int i = 0; i < 256; i++)
{
- UInt64 entry = (UInt64)i;
+ ulong entry = (ulong)i;
for(int j = 0; j < 8; j++)
if((entry & 1) == 1)
entry = (entry >> 1) ^ polynomial;
diff --git a/ChangeLog b/ChangeLog
index bfac7eeb0..d824fff64 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2016-07-28 Natalia Portillo
+
+ * CDChecksums.cs:
+ * ReedSolomon.cs:
+ * CRC16Context.cs:
+ * CRC32Context.cs:
+ * CRC64Context.cs:
+ * Adler32Context.cs:
+ * SpamSumContext.cs: Refactor and code cleanup.
+
2015-11-30 Natalia Portillo
* FletcherContext.cs:
diff --git a/ReedSolomon.cs b/ReedSolomon.cs
index 104a7321f..8fa730264 100644
--- a/ReedSolomon.cs
+++ b/ReedSolomon.cs
@@ -139,7 +139,7 @@ namespace DiscImageChef.Checksums
Pp = new[] { 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1 };
break;
default:
- throw new ArgumentOutOfRangeException("m", "m must be between 2 and 16 inclusive");
+ throw new ArgumentOutOfRangeException(nameof(m), "m must be between 2 and 16 inclusive");
}
MM = m;
diff --git a/SpamSumContext.cs b/SpamSumContext.cs
index f6bf50553..facda0ceb 100644
--- a/SpamSumContext.cs
+++ b/SpamSumContext.cs
@@ -49,13 +49,13 @@ namespace DiscImageChef.Checksums
///
public class SpamSumContext
{
- const UInt32 ROLLING_WINDOW = 7;
- const UInt32 MIN_BLOCKSIZE = 3;
- const UInt32 HASH_PRIME = 0x01000193;
- const UInt32 HASH_INIT = 0x28021967;
- const UInt32 NUM_BLOCKHASHES = 31;
- const UInt32 SPAMSUM_LENGTH = 64;
- const UInt32 FUZZY_MAX_RESULT = (2 * SPAMSUM_LENGTH + 20);
+ const uint ROLLING_WINDOW = 7;
+ const uint MIN_BLOCKSIZE = 3;
+ const uint HASH_PRIME = 0x01000193;
+ const uint HASH_INIT = 0x28021967;
+ const uint NUM_BLOCKHASHES = 31;
+ const uint SPAMSUM_LENGTH = 64;
+ const uint FUZZY_MAX_RESULT = (2 * SPAMSUM_LENGTH + 20);
//"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
readonly byte[] b64 =
{0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48,
@@ -72,10 +72,10 @@ namespace DiscImageChef.Checksums
{
public byte[] window;
// ROLLING_WINDOW
- public UInt32 h1;
- public UInt32 h2;
- public UInt32 h3;
- public UInt32 n;
+ public uint h1;
+ public uint h2;
+ public uint h3;
+ public uint n;
}
/* A blockhash contains a signature state for a specific (implicit) blocksize.
@@ -85,21 +85,21 @@ namespace DiscImageChef.Checksums
* output hash to stay compatible with ssdeep output. */
struct blockhash_context
{
- public UInt32 h;
- public UInt32 halfh;
+ public uint h;
+ public uint halfh;
public byte[] digest;
// SPAMSUM_LENGTH
public byte halfdigest;
- public UInt32 dlen;
+ public uint dlen;
}
struct fuzzy_state
{
- public UInt32 bhstart;
- public UInt32 bhend;
+ public uint bhstart;
+ public uint bhend;
public blockhash_context[] bh;
//NUM_BLOCKHASHES
- public UInt64 total_size;
+ public ulong total_size;
public roll_state roll;
}
@@ -145,10 +145,10 @@ namespace DiscImageChef.Checksums
void roll_hash(byte c)
{
self.roll.h2 -= self.roll.h1;
- self.roll.h2 += ROLLING_WINDOW * (UInt32)c;
+ self.roll.h2 += ROLLING_WINDOW * c;
- self.roll.h1 += (UInt32)c;
- self.roll.h1 -= (UInt32)self.roll.window[self.roll.n % ROLLING_WINDOW];
+ self.roll.h1 += c;
+ self.roll.h1 -= self.roll.window[self.roll.n % ROLLING_WINDOW];
self.roll.window[self.roll.n % ROLLING_WINDOW] = c;
self.roll.n++;
@@ -160,18 +160,18 @@ namespace DiscImageChef.Checksums
self.roll.h3 ^= c;
}
- UInt32 roll_sum()
+ uint roll_sum()
{
return self.roll.h1 + self.roll.h2 + self.roll.h3;
}
/* A simple non-rolling hash, based on the FNV hash. */
- static UInt32 sum_hash(byte c, UInt32 h)
+ static uint sum_hash(byte c, uint h)
{
return (h * HASH_PRIME) ^ c;
}
- static UInt32 SSDEEP_BS(UInt32 index)
+ static uint SSDEEP_BS(uint index)
{
return (MIN_BLOCKSIZE << (int)index);
}
@@ -204,7 +204,7 @@ namespace DiscImageChef.Checksums
if(self.bhend - self.bhstart < 2)
/* Need at least two working hashes. */
return;
- if((UInt64)SSDEEP_BS(self.bhstart) * SPAMSUM_LENGTH >=
+ if((ulong)SSDEEP_BS(self.bhstart) * SPAMSUM_LENGTH >=
self.total_size)
/* Initial blocksize estimate would select this or a smaller
* blocksize. */
@@ -219,8 +219,8 @@ namespace DiscImageChef.Checksums
void fuzzy_engine_step(byte c)
{
- UInt64 h;
- UInt32 i;
+ ulong h;
+ uint i;
/* At each character we update the rolling hash and the normal hashes.
* When the rolling hash hits a reset value then we emit a normal hash
* as a element of the signature and reset the normal hash. */
@@ -295,22 +295,22 @@ namespace DiscImageChef.Checksums
}
// CLAUNIA: Flags seems to never be used in ssdeep, so I just removed it for code simplicity
- UInt32 fuzzy_digest(out byte[] result)
+ uint fuzzy_digest(out byte[] result)
{
StringBuilder sb = new StringBuilder();
- UInt32 bi = self.bhstart;
- UInt32 h = roll_sum();
+ uint bi = self.bhstart;
+ uint h = roll_sum();
int i, result_off;
int remain = (int)(FUZZY_MAX_RESULT - 1); /* Exclude terminating '\0'. */
result = new byte[FUZZY_MAX_RESULT];
/* Verify that our elimination was not overeager. */
- if(!(bi == 0 || (UInt64)SSDEEP_BS(bi) / 2 * SPAMSUM_LENGTH < self.total_size))
+ if(!(bi == 0 || (ulong)SSDEEP_BS(bi) / 2 * SPAMSUM_LENGTH < self.total_size))
throw new Exception("Assertion failed");
result_off = 0;
/* Initial blocksize guess. */
- while((UInt64)SSDEEP_BS(bi) * SPAMSUM_LENGTH < self.total_size)
+ while((ulong)SSDEEP_BS(bi) * SPAMSUM_LENGTH < self.total_size)
{
++bi;
if(bi >= NUM_BLOCKHASHES)