mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
🐛Fix static method on hashes not being declared as such.
This commit is contained in:
@@ -119,11 +119,9 @@ namespace DiscImageChef.Checksums
|
|||||||
public static string File(string filename, out byte[] hash)
|
public static string File(string filename, out byte[] hash)
|
||||||
{
|
{
|
||||||
FileStream fileStream = new FileStream(filename, FileMode.Open);
|
FileStream fileStream = new FileStream(filename, FileMode.Open);
|
||||||
ushort localSum1, localSum2;
|
|
||||||
uint finalSum;
|
|
||||||
|
|
||||||
localSum1 = 1;
|
ushort localSum1 = 1;
|
||||||
localSum2 = 0;
|
ushort localSum2 = 0;
|
||||||
|
|
||||||
for(int i = 0; i < fileStream.Length; i++)
|
for(int i = 0; i < fileStream.Length; i++)
|
||||||
{
|
{
|
||||||
@@ -131,7 +129,7 @@ namespace DiscImageChef.Checksums
|
|||||||
localSum2 = (ushort)((localSum2 + localSum1) % ADLER_MODULE);
|
localSum2 = (ushort)((localSum2 + localSum1) % ADLER_MODULE);
|
||||||
}
|
}
|
||||||
|
|
||||||
finalSum = (uint)((localSum2 << 16) | localSum1);
|
uint finalSum = (uint)((localSum2 << 16) | localSum1);
|
||||||
|
|
||||||
BigEndianBitConverter.IsLittleEndian = BitConverter.IsLittleEndian;
|
BigEndianBitConverter.IsLittleEndian = BitConverter.IsLittleEndian;
|
||||||
hash = BigEndianBitConverter.GetBytes(finalSum);
|
hash = BigEndianBitConverter.GetBytes(finalSum);
|
||||||
@@ -153,11 +151,8 @@ namespace DiscImageChef.Checksums
|
|||||||
/// <param name="hash">Byte array of the hash value.</param>
|
/// <param name="hash">Byte array of the hash value.</param>
|
||||||
public static string Data(byte[] data, uint len, out byte[] hash)
|
public static string Data(byte[] data, uint len, out byte[] hash)
|
||||||
{
|
{
|
||||||
ushort localSum1, localSum2;
|
ushort localSum1 = 1;
|
||||||
uint finalSum;
|
ushort localSum2 = 0;
|
||||||
|
|
||||||
localSum1 = 1;
|
|
||||||
localSum2 = 0;
|
|
||||||
|
|
||||||
for(int i = 0; i < len; i++)
|
for(int i = 0; i < len; i++)
|
||||||
{
|
{
|
||||||
@@ -165,7 +160,7 @@ namespace DiscImageChef.Checksums
|
|||||||
localSum2 = (ushort)((localSum2 + localSum1) % ADLER_MODULE);
|
localSum2 = (ushort)((localSum2 + localSum1) % ADLER_MODULE);
|
||||||
}
|
}
|
||||||
|
|
||||||
finalSum = (uint)((localSum2 << 16) | localSum1);
|
uint finalSum = (uint)((localSum2 << 16) | localSum1);
|
||||||
|
|
||||||
BigEndianBitConverter.IsLittleEndian = BitConverter.IsLittleEndian;
|
BigEndianBitConverter.IsLittleEndian = BitConverter.IsLittleEndian;
|
||||||
hash = BigEndianBitConverter.GetBytes(finalSum);
|
hash = BigEndianBitConverter.GetBytes(finalSum);
|
||||||
|
|||||||
@@ -217,9 +217,7 @@ namespace DiscImageChef.Checksums
|
|||||||
/// <param name="seed">CRC seed</param>
|
/// <param name="seed">CRC seed</param>
|
||||||
public static string Data(byte[] data, uint len, out byte[] hash, uint polynomial, uint seed)
|
public static string Data(byte[] data, uint len, out byte[] hash, uint polynomial, uint seed)
|
||||||
{
|
{
|
||||||
uint localhashInt;
|
uint localhashInt = seed;
|
||||||
|
|
||||||
localhashInt = seed;
|
|
||||||
|
|
||||||
uint[] localTable = new uint[256];
|
uint[] localTable = new uint[256];
|
||||||
for(int i = 0; i < 256; i++)
|
for(int i = 0; i < 256; i++)
|
||||||
|
|||||||
@@ -173,12 +173,11 @@ namespace DiscImageChef.Checksums
|
|||||||
public static string File(string filename, out byte[] hash)
|
public static string File(string filename, out byte[] hash)
|
||||||
{
|
{
|
||||||
FileStream fileStream = new FileStream(filename, FileMode.Open);
|
FileStream fileStream = new FileStream(filename, FileMode.Open);
|
||||||
ushort localSum1, localSum2, block;
|
ushort block;
|
||||||
uint finalSum;
|
|
||||||
byte[] blockBytes;
|
byte[] blockBytes;
|
||||||
|
|
||||||
localSum1 = 0xFFFF;
|
ushort localSum1 = 0xFFFF;
|
||||||
localSum2 = 0xFFFF;
|
ushort localSum2 = 0xFFFF;
|
||||||
|
|
||||||
if(fileStream.Length % 2 == 0)
|
if(fileStream.Length % 2 == 0)
|
||||||
for(int i = 0; i < fileStream.Length; i += 2)
|
for(int i = 0; i < fileStream.Length; i += 2)
|
||||||
@@ -209,7 +208,7 @@ namespace DiscImageChef.Checksums
|
|||||||
localSum2 = (ushort)((localSum2 + localSum1) % 0xFFFF);
|
localSum2 = (ushort)((localSum2 + localSum1) % 0xFFFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
finalSum = (uint)(localSum1 + (localSum2 << 16));
|
uint finalSum = (uint)(localSum1 + (localSum2 << 16));
|
||||||
|
|
||||||
hash = BitConverter.GetBytes(finalSum);
|
hash = BitConverter.GetBytes(finalSum);
|
||||||
|
|
||||||
@@ -228,11 +227,10 @@ namespace DiscImageChef.Checksums
|
|||||||
/// <param name="hash">Byte array of the hash value.</param>
|
/// <param name="hash">Byte array of the hash value.</param>
|
||||||
public static string Data(byte[] data, uint len, out byte[] hash)
|
public static string Data(byte[] data, uint len, out byte[] hash)
|
||||||
{
|
{
|
||||||
ushort localSum1, localSum2, block;
|
ushort block;
|
||||||
uint finalSum;
|
|
||||||
|
|
||||||
localSum1 = 0xFFFF;
|
ushort localSum1 = 0xFFFF;
|
||||||
localSum2 = 0xFFFF;
|
ushort localSum2 = 0xFFFF;
|
||||||
|
|
||||||
if(len % 2 == 0)
|
if(len % 2 == 0)
|
||||||
for(int i = 0; i < len; i += 2)
|
for(int i = 0; i < len; i += 2)
|
||||||
@@ -259,7 +257,7 @@ namespace DiscImageChef.Checksums
|
|||||||
localSum2 = (ushort)((localSum2 + localSum1) % 0xFFFF);
|
localSum2 = (ushort)((localSum2 + localSum1) % 0xFFFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
finalSum = (uint)(localSum1 + (localSum2 << 16));
|
uint finalSum = (uint)(localSum1 + (localSum2 << 16));
|
||||||
|
|
||||||
hash = BitConverter.GetBytes(finalSum);
|
hash = BitConverter.GetBytes(finalSum);
|
||||||
|
|
||||||
@@ -281,14 +279,14 @@ namespace DiscImageChef.Checksums
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Fletcher16Context
|
public class Fletcher16Context : IChecksum
|
||||||
{
|
{
|
||||||
byte sum1, sum2;
|
byte sum1, sum2;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes the Fletcher16 sums
|
/// Initializes the Fletcher16 sums
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void Init()
|
public Fletcher16Context()
|
||||||
{
|
{
|
||||||
sum1 = 0xFF;
|
sum1 = 0xFF;
|
||||||
sum2 = 0xFF;
|
sum2 = 0xFF;
|
||||||
@@ -358,20 +356,18 @@ namespace DiscImageChef.Checksums
|
|||||||
public static string File(string filename, out byte[] hash)
|
public static string File(string filename, out byte[] hash)
|
||||||
{
|
{
|
||||||
FileStream fileStream = new FileStream(filename, FileMode.Open);
|
FileStream fileStream = new FileStream(filename, FileMode.Open);
|
||||||
byte localSum1, localSum2, block;
|
|
||||||
ushort finalSum;
|
|
||||||
|
|
||||||
localSum1 = 0xFF;
|
byte localSum1 = 0xFF;
|
||||||
localSum2 = 0xFF;
|
byte localSum2 = 0xFF;
|
||||||
|
|
||||||
for(int i = 0; i < fileStream.Length; i += 2)
|
for(int i = 0; i < fileStream.Length; i += 2)
|
||||||
{
|
{
|
||||||
block = (byte)fileStream.ReadByte();
|
byte block = (byte)fileStream.ReadByte();
|
||||||
localSum1 = (byte)((localSum1 + block) % 0xFF);
|
localSum1 = (byte)((localSum1 + block) % 0xFF);
|
||||||
localSum2 = (byte)((localSum2 + localSum1) % 0xFF);
|
localSum2 = (byte)((localSum2 + localSum1) % 0xFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
finalSum = (ushort)(localSum1 + (localSum2 << 8));
|
ushort finalSum = (ushort)(localSum1 + (localSum2 << 8));
|
||||||
|
|
||||||
hash = BitConverter.GetBytes(finalSum);
|
hash = BitConverter.GetBytes(finalSum);
|
||||||
|
|
||||||
@@ -390,11 +386,8 @@ namespace DiscImageChef.Checksums
|
|||||||
/// <param name="hash">Byte array of the hash value.</param>
|
/// <param name="hash">Byte array of the hash value.</param>
|
||||||
public static string Data(byte[] data, uint len, out byte[] hash)
|
public static string Data(byte[] data, uint len, out byte[] hash)
|
||||||
{
|
{
|
||||||
byte localSum1, localSum2;
|
byte localSum1 = 0xFF;
|
||||||
ushort finalSum;
|
byte localSum2 = 0xFF;
|
||||||
|
|
||||||
localSum1 = 0xFF;
|
|
||||||
localSum2 = 0xFF;
|
|
||||||
|
|
||||||
for(int i = 0; i < len; i++)
|
for(int i = 0; i < len; i++)
|
||||||
{
|
{
|
||||||
@@ -402,7 +395,7 @@ namespace DiscImageChef.Checksums
|
|||||||
localSum2 = (byte)((localSum2 + localSum1) % 0xFF);
|
localSum2 = (byte)((localSum2 + localSum1) % 0xFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
finalSum = (ushort)(localSum1 + (localSum2 << 8));
|
ushort finalSum = (ushort)(localSum1 + (localSum2 << 8));
|
||||||
|
|
||||||
hash = BitConverter.GetBytes(finalSum);
|
hash = BitConverter.GetBytes(finalSum);
|
||||||
|
|
||||||
|
|||||||
@@ -96,10 +96,11 @@ namespace DiscImageChef.Checksums
|
|||||||
/// Gets the hash of a file
|
/// Gets the hash of a file
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="filename">File path.</param>
|
/// <param name="filename">File path.</param>
|
||||||
public byte[] File(string filename)
|
public static byte[] File(string filename)
|
||||||
{
|
{
|
||||||
|
MD5 localMd5Provider = MD5.Create();
|
||||||
FileStream fileStream = new FileStream(filename, FileMode.Open);
|
FileStream fileStream = new FileStream(filename, FileMode.Open);
|
||||||
byte[] result = md5Provider.ComputeHash(fileStream);
|
byte[] result = localMd5Provider.ComputeHash(fileStream);
|
||||||
fileStream.Close();
|
fileStream.Close();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -109,10 +110,11 @@ namespace DiscImageChef.Checksums
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="filename">File path.</param>
|
/// <param name="filename">File path.</param>
|
||||||
/// <param name="hash">Byte array of the hash value.</param>
|
/// <param name="hash">Byte array of the hash value.</param>
|
||||||
public string File(string filename, out byte[] hash)
|
public static string File(string filename, out byte[] hash)
|
||||||
{
|
{
|
||||||
|
MD5 localMd5Provider = MD5.Create();
|
||||||
FileStream fileStream = new FileStream(filename, FileMode.Open);
|
FileStream fileStream = new FileStream(filename, FileMode.Open);
|
||||||
hash = md5Provider.ComputeHash(fileStream);
|
hash = localMd5Provider.ComputeHash(fileStream);
|
||||||
StringBuilder md5Output = new StringBuilder();
|
StringBuilder md5Output = new StringBuilder();
|
||||||
|
|
||||||
foreach(byte h in hash) md5Output.Append(h.ToString("x2"));
|
foreach(byte h in hash) md5Output.Append(h.ToString("x2"));
|
||||||
@@ -128,9 +130,10 @@ namespace DiscImageChef.Checksums
|
|||||||
/// <param name="data">Data buffer.</param>
|
/// <param name="data">Data buffer.</param>
|
||||||
/// <param name="len">Length of the data buffer to hash.</param>
|
/// <param name="len">Length of the data buffer to hash.</param>
|
||||||
/// <param name="hash">Byte array of the hash value.</param>
|
/// <param name="hash">Byte array of the hash value.</param>
|
||||||
public string Data(byte[] data, uint len, out byte[] hash)
|
public static string Data(byte[] data, uint len, out byte[] hash)
|
||||||
{
|
{
|
||||||
hash = md5Provider.ComputeHash(data, 0, (int)len);
|
MD5 localMd5Provider = MD5.Create();
|
||||||
|
hash = localMd5Provider.ComputeHash(data, 0, (int)len);
|
||||||
StringBuilder md5Output = new StringBuilder();
|
StringBuilder md5Output = new StringBuilder();
|
||||||
|
|
||||||
foreach(byte h in hash) md5Output.Append(h.ToString("x2"));
|
foreach(byte h in hash) md5Output.Append(h.ToString("x2"));
|
||||||
@@ -143,7 +146,7 @@ namespace DiscImageChef.Checksums
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="data">Data buffer.</param>
|
/// <param name="data">Data buffer.</param>
|
||||||
/// <param name="hash">Byte array of the hash value.</param>
|
/// <param name="hash">Byte array of the hash value.</param>
|
||||||
public string Data(byte[] data, out byte[] hash)
|
public static string Data(byte[] data, out byte[] hash)
|
||||||
{
|
{
|
||||||
return Data(data, (uint)data.Length, out hash);
|
return Data(data, (uint)data.Length, out hash);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -96,10 +96,11 @@ namespace DiscImageChef.Checksums
|
|||||||
/// Gets the hash of a file
|
/// Gets the hash of a file
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="filename">File path.</param>
|
/// <param name="filename">File path.</param>
|
||||||
public byte[] File(string filename)
|
public static byte[] File(string filename)
|
||||||
{
|
{
|
||||||
|
RIPEMD160 localRipemd160Provider = RIPEMD160.Create();
|
||||||
FileStream fileStream = new FileStream(filename, FileMode.Open);
|
FileStream fileStream = new FileStream(filename, FileMode.Open);
|
||||||
byte[] result = ripemd160Provider.ComputeHash(fileStream);
|
byte[] result = localRipemd160Provider.ComputeHash(fileStream);
|
||||||
fileStream.Close();
|
fileStream.Close();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -109,10 +110,11 @@ namespace DiscImageChef.Checksums
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="filename">File path.</param>
|
/// <param name="filename">File path.</param>
|
||||||
/// <param name="hash">Byte array of the hash value.</param>
|
/// <param name="hash">Byte array of the hash value.</param>
|
||||||
public string File(string filename, out byte[] hash)
|
public static string File(string filename, out byte[] hash)
|
||||||
{
|
{
|
||||||
|
RIPEMD160 localRipemd160Provider = RIPEMD160.Create();
|
||||||
FileStream fileStream = new FileStream(filename, FileMode.Open);
|
FileStream fileStream = new FileStream(filename, FileMode.Open);
|
||||||
hash = ripemd160Provider.ComputeHash(fileStream);
|
hash = localRipemd160Provider.ComputeHash(fileStream);
|
||||||
StringBuilder ripemd160Output = new StringBuilder();
|
StringBuilder ripemd160Output = new StringBuilder();
|
||||||
|
|
||||||
foreach(byte h in hash) ripemd160Output.Append(h.ToString("x2"));
|
foreach(byte h in hash) ripemd160Output.Append(h.ToString("x2"));
|
||||||
@@ -128,9 +130,10 @@ namespace DiscImageChef.Checksums
|
|||||||
/// <param name="data">Data buffer.</param>
|
/// <param name="data">Data buffer.</param>
|
||||||
/// <param name="len">Length of the data buffer to hash.</param>
|
/// <param name="len">Length of the data buffer to hash.</param>
|
||||||
/// <param name="hash">Byte array of the hash value.</param>
|
/// <param name="hash">Byte array of the hash value.</param>
|
||||||
public string Data(byte[] data, uint len, out byte[] hash)
|
public static string Data(byte[] data, uint len, out byte[] hash)
|
||||||
{
|
{
|
||||||
hash = ripemd160Provider.ComputeHash(data, 0, (int)len);
|
RIPEMD160 localRipemd160Provider = RIPEMD160.Create();
|
||||||
|
hash = localRipemd160Provider.ComputeHash(data, 0, (int)len);
|
||||||
StringBuilder ripemd160Output = new StringBuilder();
|
StringBuilder ripemd160Output = new StringBuilder();
|
||||||
|
|
||||||
foreach(byte h in hash) ripemd160Output.Append(h.ToString("x2"));
|
foreach(byte h in hash) ripemd160Output.Append(h.ToString("x2"));
|
||||||
@@ -143,7 +146,7 @@ namespace DiscImageChef.Checksums
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="data">Data buffer.</param>
|
/// <param name="data">Data buffer.</param>
|
||||||
/// <param name="hash">Byte array of the hash value.</param>
|
/// <param name="hash">Byte array of the hash value.</param>
|
||||||
public string Data(byte[] data, out byte[] hash)
|
public static string Data(byte[] data, out byte[] hash)
|
||||||
{
|
{
|
||||||
return Data(data, (uint)data.Length, out hash);
|
return Data(data, (uint)data.Length, out hash);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -96,10 +96,11 @@ namespace DiscImageChef.Checksums
|
|||||||
/// Gets the hash of a file
|
/// Gets the hash of a file
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="filename">File path.</param>
|
/// <param name="filename">File path.</param>
|
||||||
public byte[] File(string filename)
|
public static byte[] File(string filename)
|
||||||
{
|
{
|
||||||
|
SHA1 localSha1Provider = SHA1.Create();
|
||||||
FileStream fileStream = new FileStream(filename, FileMode.Open);
|
FileStream fileStream = new FileStream(filename, FileMode.Open);
|
||||||
byte[] result = sha1Provider.ComputeHash(fileStream);
|
byte[] result = localSha1Provider.ComputeHash(fileStream);
|
||||||
fileStream.Close();
|
fileStream.Close();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -109,10 +110,11 @@ namespace DiscImageChef.Checksums
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="filename">File path.</param>
|
/// <param name="filename">File path.</param>
|
||||||
/// <param name="hash">Byte array of the hash value.</param>
|
/// <param name="hash">Byte array of the hash value.</param>
|
||||||
public string File(string filename, out byte[] hash)
|
public static string File(string filename, out byte[] hash)
|
||||||
{
|
{
|
||||||
|
SHA1 localSha1Provider = SHA1.Create();
|
||||||
FileStream fileStream = new FileStream(filename, FileMode.Open);
|
FileStream fileStream = new FileStream(filename, FileMode.Open);
|
||||||
hash = sha1Provider.ComputeHash(fileStream);
|
hash = localSha1Provider.ComputeHash(fileStream);
|
||||||
StringBuilder sha1Output = new StringBuilder();
|
StringBuilder sha1Output = new StringBuilder();
|
||||||
|
|
||||||
foreach(byte h in hash) sha1Output.Append(h.ToString("x2"));
|
foreach(byte h in hash) sha1Output.Append(h.ToString("x2"));
|
||||||
@@ -128,9 +130,10 @@ namespace DiscImageChef.Checksums
|
|||||||
/// <param name="data">Data buffer.</param>
|
/// <param name="data">Data buffer.</param>
|
||||||
/// <param name="len">Length of the data buffer to hash.</param>
|
/// <param name="len">Length of the data buffer to hash.</param>
|
||||||
/// <param name="hash">Byte array of the hash value.</param>
|
/// <param name="hash">Byte array of the hash value.</param>
|
||||||
public string Data(byte[] data, uint len, out byte[] hash)
|
public static string Data(byte[] data, uint len, out byte[] hash)
|
||||||
{
|
{
|
||||||
hash = sha1Provider.ComputeHash(data, 0, (int)len);
|
SHA1 localSha1Provider = SHA1.Create();
|
||||||
|
hash = localSha1Provider.ComputeHash(data, 0, (int)len);
|
||||||
StringBuilder sha1Output = new StringBuilder();
|
StringBuilder sha1Output = new StringBuilder();
|
||||||
|
|
||||||
foreach(byte h in hash) sha1Output.Append(h.ToString("x2"));
|
foreach(byte h in hash) sha1Output.Append(h.ToString("x2"));
|
||||||
@@ -143,7 +146,7 @@ namespace DiscImageChef.Checksums
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="data">Data buffer.</param>
|
/// <param name="data">Data buffer.</param>
|
||||||
/// <param name="hash">Byte array of the hash value.</param>
|
/// <param name="hash">Byte array of the hash value.</param>
|
||||||
public string Data(byte[] data, out byte[] hash)
|
public static string Data(byte[] data, out byte[] hash)
|
||||||
{
|
{
|
||||||
return Data(data, (uint)data.Length, out hash);
|
return Data(data, (uint)data.Length, out hash);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -96,10 +96,11 @@ namespace DiscImageChef.Checksums
|
|||||||
/// Gets the hash of a file
|
/// Gets the hash of a file
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="filename">File path.</param>
|
/// <param name="filename">File path.</param>
|
||||||
public byte[] File(string filename)
|
public static byte[] File(string filename)
|
||||||
{
|
{
|
||||||
|
SHA256 localSha256Provider = SHA256.Create();
|
||||||
FileStream fileStream = new FileStream(filename, FileMode.Open);
|
FileStream fileStream = new FileStream(filename, FileMode.Open);
|
||||||
byte[] result = sha256Provider.ComputeHash(fileStream);
|
byte[] result = localSha256Provider.ComputeHash(fileStream);
|
||||||
fileStream.Close();
|
fileStream.Close();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -109,10 +110,11 @@ namespace DiscImageChef.Checksums
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="filename">File path.</param>
|
/// <param name="filename">File path.</param>
|
||||||
/// <param name="hash">Byte array of the hash value.</param>
|
/// <param name="hash">Byte array of the hash value.</param>
|
||||||
public string File(string filename, out byte[] hash)
|
public static string File(string filename, out byte[] hash)
|
||||||
{
|
{
|
||||||
|
SHA256 localSha256Provider = SHA256.Create();
|
||||||
FileStream fileStream = new FileStream(filename, FileMode.Open);
|
FileStream fileStream = new FileStream(filename, FileMode.Open);
|
||||||
hash = sha256Provider.ComputeHash(fileStream);
|
hash = localSha256Provider.ComputeHash(fileStream);
|
||||||
StringBuilder sha256Output = new StringBuilder();
|
StringBuilder sha256Output = new StringBuilder();
|
||||||
|
|
||||||
foreach(byte h in hash) sha256Output.Append(h.ToString("x2"));
|
foreach(byte h in hash) sha256Output.Append(h.ToString("x2"));
|
||||||
@@ -128,9 +130,10 @@ namespace DiscImageChef.Checksums
|
|||||||
/// <param name="data">Data buffer.</param>
|
/// <param name="data">Data buffer.</param>
|
||||||
/// <param name="len">Length of the data buffer to hash.</param>
|
/// <param name="len">Length of the data buffer to hash.</param>
|
||||||
/// <param name="hash">Byte array of the hash value.</param>
|
/// <param name="hash">Byte array of the hash value.</param>
|
||||||
public string Data(byte[] data, uint len, out byte[] hash)
|
public static string Data(byte[] data, uint len, out byte[] hash)
|
||||||
{
|
{
|
||||||
hash = sha256Provider.ComputeHash(data, 0, (int)len);
|
SHA256 localSha256Provider = SHA256.Create();
|
||||||
|
hash = localSha256Provider.ComputeHash(data, 0, (int)len);
|
||||||
StringBuilder sha256Output = new StringBuilder();
|
StringBuilder sha256Output = new StringBuilder();
|
||||||
|
|
||||||
foreach(byte h in hash) sha256Output.Append(h.ToString("x2"));
|
foreach(byte h in hash) sha256Output.Append(h.ToString("x2"));
|
||||||
@@ -143,7 +146,7 @@ namespace DiscImageChef.Checksums
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="data">Data buffer.</param>
|
/// <param name="data">Data buffer.</param>
|
||||||
/// <param name="hash">Byte array of the hash value.</param>
|
/// <param name="hash">Byte array of the hash value.</param>
|
||||||
public string Data(byte[] data, out byte[] hash)
|
public static string Data(byte[] data, out byte[] hash)
|
||||||
{
|
{
|
||||||
return Data(data, (uint)data.Length, out hash);
|
return Data(data, (uint)data.Length, out hash);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -96,10 +96,11 @@ namespace DiscImageChef.Checksums
|
|||||||
/// Gets the hash of a file
|
/// Gets the hash of a file
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="filename">File path.</param>
|
/// <param name="filename">File path.</param>
|
||||||
public byte[] File(string filename)
|
public static byte[] File(string filename)
|
||||||
{
|
{
|
||||||
|
SHA384 localSha384Provider = SHA384.Create();
|
||||||
FileStream fileStream = new FileStream(filename, FileMode.Open);
|
FileStream fileStream = new FileStream(filename, FileMode.Open);
|
||||||
byte[] result = sha384Provider.ComputeHash(fileStream);
|
byte[] result = localSha384Provider.ComputeHash(fileStream);
|
||||||
fileStream.Close();
|
fileStream.Close();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -109,10 +110,11 @@ namespace DiscImageChef.Checksums
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="filename">File path.</param>
|
/// <param name="filename">File path.</param>
|
||||||
/// <param name="hash">Byte array of the hash value.</param>
|
/// <param name="hash">Byte array of the hash value.</param>
|
||||||
public string File(string filename, out byte[] hash)
|
public static string File(string filename, out byte[] hash)
|
||||||
{
|
{
|
||||||
|
SHA384 localSha384Provider = SHA384.Create();
|
||||||
FileStream fileStream = new FileStream(filename, FileMode.Open);
|
FileStream fileStream = new FileStream(filename, FileMode.Open);
|
||||||
hash = sha384Provider.ComputeHash(fileStream);
|
hash = localSha384Provider.ComputeHash(fileStream);
|
||||||
StringBuilder sha384Output = new StringBuilder();
|
StringBuilder sha384Output = new StringBuilder();
|
||||||
|
|
||||||
foreach(byte h in hash) sha384Output.Append(h.ToString("x2"));
|
foreach(byte h in hash) sha384Output.Append(h.ToString("x2"));
|
||||||
@@ -128,9 +130,10 @@ namespace DiscImageChef.Checksums
|
|||||||
/// <param name="data">Data buffer.</param>
|
/// <param name="data">Data buffer.</param>
|
||||||
/// <param name="len">Length of the data buffer to hash.</param>
|
/// <param name="len">Length of the data buffer to hash.</param>
|
||||||
/// <param name="hash">Byte array of the hash value.</param>
|
/// <param name="hash">Byte array of the hash value.</param>
|
||||||
public string Data(byte[] data, uint len, out byte[] hash)
|
public static string Data(byte[] data, uint len, out byte[] hash)
|
||||||
{
|
{
|
||||||
hash = sha384Provider.ComputeHash(data, 0, (int)len);
|
SHA384 localSha384Provider = SHA384.Create();
|
||||||
|
hash = localSha384Provider.ComputeHash(data, 0, (int)len);
|
||||||
StringBuilder sha384Output = new StringBuilder();
|
StringBuilder sha384Output = new StringBuilder();
|
||||||
|
|
||||||
foreach(byte h in hash) sha384Output.Append(h.ToString("x2"));
|
foreach(byte h in hash) sha384Output.Append(h.ToString("x2"));
|
||||||
@@ -143,7 +146,7 @@ namespace DiscImageChef.Checksums
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="data">Data buffer.</param>
|
/// <param name="data">Data buffer.</param>
|
||||||
/// <param name="hash">Byte array of the hash value.</param>
|
/// <param name="hash">Byte array of the hash value.</param>
|
||||||
public string Data(byte[] data, out byte[] hash)
|
public static string Data(byte[] data, out byte[] hash)
|
||||||
{
|
{
|
||||||
return Data(data, (uint)data.Length, out hash);
|
return Data(data, (uint)data.Length, out hash);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -96,10 +96,11 @@ namespace DiscImageChef.Checksums
|
|||||||
/// Gets the hash of a file
|
/// Gets the hash of a file
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="filename">File path.</param>
|
/// <param name="filename">File path.</param>
|
||||||
public byte[] File(string filename)
|
public static byte[] File(string filename)
|
||||||
{
|
{
|
||||||
|
SHA512 localSha512Provider = SHA512.Create();
|
||||||
FileStream fileStream = new FileStream(filename, FileMode.Open);
|
FileStream fileStream = new FileStream(filename, FileMode.Open);
|
||||||
byte[] result = sha512Provider.ComputeHash(fileStream);
|
byte[] result = localSha512Provider.ComputeHash(fileStream);
|
||||||
fileStream.Close();
|
fileStream.Close();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -109,10 +110,11 @@ namespace DiscImageChef.Checksums
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="filename">File path.</param>
|
/// <param name="filename">File path.</param>
|
||||||
/// <param name="hash">Byte array of the hash value.</param>
|
/// <param name="hash">Byte array of the hash value.</param>
|
||||||
public string File(string filename, out byte[] hash)
|
public static string File(string filename, out byte[] hash)
|
||||||
{
|
{
|
||||||
|
SHA512 localSha512Provider = SHA512.Create();
|
||||||
FileStream fileStream = new FileStream(filename, FileMode.Open);
|
FileStream fileStream = new FileStream(filename, FileMode.Open);
|
||||||
hash = sha512Provider.ComputeHash(fileStream);
|
hash = localSha512Provider.ComputeHash(fileStream);
|
||||||
StringBuilder sha512Output = new StringBuilder();
|
StringBuilder sha512Output = new StringBuilder();
|
||||||
|
|
||||||
foreach(byte h in hash) sha512Output.Append(h.ToString("x2"));
|
foreach(byte h in hash) sha512Output.Append(h.ToString("x2"));
|
||||||
@@ -128,9 +130,10 @@ namespace DiscImageChef.Checksums
|
|||||||
/// <param name="data">Data buffer.</param>
|
/// <param name="data">Data buffer.</param>
|
||||||
/// <param name="len">Length of the data buffer to hash.</param>
|
/// <param name="len">Length of the data buffer to hash.</param>
|
||||||
/// <param name="hash">Byte array of the hash value.</param>
|
/// <param name="hash">Byte array of the hash value.</param>
|
||||||
public string Data(byte[] data, uint len, out byte[] hash)
|
public static string Data(byte[] data, uint len, out byte[] hash)
|
||||||
{
|
{
|
||||||
hash = sha512Provider.ComputeHash(data, 0, (int)len);
|
SHA512 localSha512Provider = SHA512.Create();
|
||||||
|
hash = localSha512Provider.ComputeHash(data, 0, (int)len);
|
||||||
StringBuilder sha512Output = new StringBuilder();
|
StringBuilder sha512Output = new StringBuilder();
|
||||||
|
|
||||||
foreach(byte h in hash) sha512Output.Append(h.ToString("x2"));
|
foreach(byte h in hash) sha512Output.Append(h.ToString("x2"));
|
||||||
@@ -143,7 +146,7 @@ namespace DiscImageChef.Checksums
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="data">Data buffer.</param>
|
/// <param name="data">Data buffer.</param>
|
||||||
/// <param name="hash">Byte array of the hash value.</param>
|
/// <param name="hash">Byte array of the hash value.</param>
|
||||||
public string Data(byte[] data, out byte[] hash)
|
public static string Data(byte[] data, out byte[] hash)
|
||||||
{
|
{
|
||||||
return Data(data, (uint)data.Length, out hash);
|
return Data(data, (uint)data.Length, out hash);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -704,7 +704,6 @@ namespace DiscImageChef.Filesystems
|
|||||||
ulong rootDirectorySector = 0;
|
ulong rootDirectorySector = 0;
|
||||||
string extraInfo = null;
|
string extraInfo = null;
|
||||||
string bootChk = null;
|
string bootChk = null;
|
||||||
Sha1Context sha1Ctx = new Sha1Context();
|
|
||||||
|
|
||||||
// This is needed because for FAT16, GEMDOS increases bytes per sector count instead of using big_sectors field.
|
// This is needed because for FAT16, GEMDOS increases bytes per sector count instead of using big_sectors field.
|
||||||
uint sectorsPerRealSector;
|
uint sectorsPerRealSector;
|
||||||
@@ -1036,9 +1035,9 @@ namespace DiscImageChef.Filesystems
|
|||||||
{
|
{
|
||||||
XmlFsType.VolumeName = Encoding.ASCII.GetString(fat32Bpb.volume_label);
|
XmlFsType.VolumeName = Encoding.ASCII.GetString(fat32Bpb.volume_label);
|
||||||
sb.AppendFormat("Filesystem type: {0}", Encoding.ASCII.GetString(fat32Bpb.fs_type)).AppendLine();
|
sb.AppendFormat("Filesystem type: {0}", Encoding.ASCII.GetString(fat32Bpb.fs_type)).AppendLine();
|
||||||
bootChk = sha1Ctx.Data(fat32Bpb.boot_code, out _);
|
bootChk = Sha1Context.Data(fat32Bpb.boot_code, out _);
|
||||||
}
|
}
|
||||||
else bootChk = sha1Ctx.Data(shortFat32Bpb.boot_code, out _);
|
else bootChk = Sha1Context.Data(shortFat32Bpb.boot_code, out _);
|
||||||
|
|
||||||
// Check that jumps to a correct boot code position and has boot signature set.
|
// Check that jumps to a correct boot code position and has boot signature set.
|
||||||
// This will mean that the volume will boot, even if just to say "this is not bootable change disk"......
|
// This will mean that the volume will boot, even if just to say "this is not bootable change disk"......
|
||||||
@@ -1426,7 +1425,7 @@ namespace DiscImageChef.Filesystems
|
|||||||
else if(useAtariBpb && XmlFsType.VolumeSerial != null)
|
else if(useAtariBpb && XmlFsType.VolumeSerial != null)
|
||||||
sb.AppendFormat("Volume Serial Number: {0}", XmlFsType.VolumeSerial).AppendLine();
|
sb.AppendFormat("Volume Serial Number: {0}", XmlFsType.VolumeSerial).AppendLine();
|
||||||
|
|
||||||
bootChk = sha1Ctx.Data(fakeBpb.boot_code, out _);
|
bootChk = Sha1Context.Data(fakeBpb.boot_code, out _);
|
||||||
|
|
||||||
// Workaround that PCExchange jumps into "FAT16 "...
|
// Workaround that PCExchange jumps into "FAT16 "...
|
||||||
if(XmlFsType.SystemIdentifier == "PCX 2.0 ") fakeBpb.jump[1] += 8;
|
if(XmlFsType.SystemIdentifier == "PCX 2.0 ") fakeBpb.jump[1] += 8;
|
||||||
@@ -1525,9 +1524,7 @@ namespace DiscImageChef.Filesystems
|
|||||||
int sigSize = bpbSector[510] == 0x55 && bpbSector[511] == 0xAA ? 2 : 0;
|
int sigSize = bpbSector[510] == 0x55 && bpbSector[511] == 0xAA ? 2 : 0;
|
||||||
byte[] bootCode = new byte[512 - sigSize - bpbSector[1] - 2];
|
byte[] bootCode = new byte[512 - sigSize - bpbSector[1] - 2];
|
||||||
Array.Copy(bpbSector, bpbSector[1] + 2, bootCode, 0, bootCode.Length);
|
Array.Copy(bpbSector, bpbSector[1] + 2, bootCode, 0, bootCode.Length);
|
||||||
sha1Ctx = new Sha1Context();
|
Sha1Context.Data(bootCode, out _);
|
||||||
sha1Ctx.Update(bootCode);
|
|
||||||
bootChk = sha1Ctx.End();
|
|
||||||
}
|
}
|
||||||
// Intel big jump
|
// Intel big jump
|
||||||
else if(bpbSector[0] == 0xE9 && BitConverter.ToUInt16(bpbSector, 1) < 0x1FC)
|
else if(bpbSector[0] == 0xE9 && BitConverter.ToUInt16(bpbSector, 1) < 0x1FC)
|
||||||
@@ -1536,9 +1533,7 @@ namespace DiscImageChef.Filesystems
|
|||||||
byte[] bootCode = new byte[512 - sigSize - BitConverter.ToUInt16(bpbSector, 1) - 3];
|
byte[] bootCode = new byte[512 - sigSize - BitConverter.ToUInt16(bpbSector, 1) - 3];
|
||||||
Array.Copy(bpbSector, BitConverter.ToUInt16(bpbSector, 1) + 3, bootCode, 0,
|
Array.Copy(bpbSector, BitConverter.ToUInt16(bpbSector, 1) + 3, bootCode, 0,
|
||||||
bootCode.Length);
|
bootCode.Length);
|
||||||
sha1Ctx = new Sha1Context();
|
Sha1Context.Data(bootCode, out _);
|
||||||
sha1Ctx.Update(bootCode);
|
|
||||||
bootChk = sha1Ctx.End();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sb.AppendLine("Volume is bootable");
|
sb.AppendLine("Volume is bootable");
|
||||||
|
|||||||
@@ -186,8 +186,7 @@ namespace DiscImageChef.Filesystems
|
|||||||
hpfsBpb.signature2 == 0xAA55)
|
hpfsBpb.signature2 == 0xAA55)
|
||||||
{
|
{
|
||||||
XmlFsType.Bootable = true;
|
XmlFsType.Bootable = true;
|
||||||
Sha1Context sha1Ctx = new Sha1Context();
|
string bootChk = Sha1Context.Data(hpfsBpb.boot_code, out byte[] _);
|
||||||
string bootChk = sha1Ctx.Data(hpfsBpb.boot_code, out byte[] sha1_out);
|
|
||||||
sb.AppendLine("Volume is bootable");
|
sb.AppendLine("Volume is bootable");
|
||||||
sb.AppendFormat("Boot code's SHA1: {0}", bootChk).AppendLine();
|
sb.AppendFormat("Boot code's SHA1: {0}", bootChk).AppendLine();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -568,7 +568,6 @@ namespace DiscImageChef.Filesystems.ISO9660
|
|||||||
if(torito != null)
|
if(torito != null)
|
||||||
{
|
{
|
||||||
vdSector = imagePlugin.ReadSector(torito.Value.catalog_sector + partition.Start);
|
vdSector = imagePlugin.ReadSector(torito.Value.catalog_sector + partition.Start);
|
||||||
Sha1Context sha1Ctx = new Sha1Context();
|
|
||||||
|
|
||||||
int toritoOff = 0;
|
int toritoOff = 0;
|
||||||
|
|
||||||
@@ -642,7 +641,7 @@ namespace DiscImageChef.Filesystems.ISO9660
|
|||||||
|
|
||||||
isoMetadata.AppendFormat("\tSystem type: 0x{0:X2}", initialEntry.system_type).AppendLine();
|
isoMetadata.AppendFormat("\tSystem type: 0x{0:X2}", initialEntry.system_type).AppendLine();
|
||||||
if(bootImage != null)
|
if(bootImage != null)
|
||||||
isoMetadata.AppendFormat("\tBootable image's SHA1: {0}", sha1Ctx.Data(bootImage, out _))
|
isoMetadata.AppendFormat("\tBootable image's SHA1: {0}", Sha1Context.Data(bootImage, out _))
|
||||||
.AppendLine();
|
.AppendLine();
|
||||||
}
|
}
|
||||||
else isoMetadata.AppendLine("\tNot bootable");
|
else isoMetadata.AppendLine("\tNot bootable");
|
||||||
@@ -725,7 +724,7 @@ namespace DiscImageChef.Filesystems.ISO9660
|
|||||||
.AppendLine();
|
.AppendLine();
|
||||||
if(bootImage != null)
|
if(bootImage != null)
|
||||||
isoMetadata.AppendFormat("\t\tBootable image's SHA1: {0}",
|
isoMetadata.AppendFormat("\t\tBootable image's SHA1: {0}",
|
||||||
sha1Ctx.Data(bootImage, out _)).AppendLine();
|
Sha1Context.Data(bootImage, out _)).AppendLine();
|
||||||
}
|
}
|
||||||
else isoMetadata.AppendLine("\t\tNot bootable");
|
else isoMetadata.AppendLine("\t\tNot bootable");
|
||||||
|
|
||||||
|
|||||||
@@ -123,8 +123,7 @@ namespace DiscImageChef.Filesystems
|
|||||||
if(ntfsBb.jump[0] == 0xEB && ntfsBb.jump[1] > 0x4E && ntfsBb.jump[1] < 0x80 && ntfsBb.signature2 == 0xAA55)
|
if(ntfsBb.jump[0] == 0xEB && ntfsBb.jump[1] > 0x4E && ntfsBb.jump[1] < 0x80 && ntfsBb.signature2 == 0xAA55)
|
||||||
{
|
{
|
||||||
XmlFsType.Bootable = true;
|
XmlFsType.Bootable = true;
|
||||||
Sha1Context sha1Ctx = new Sha1Context();
|
string bootChk = Sha1Context.Data(ntfsBb.boot_code, out _);
|
||||||
string bootChk = sha1Ctx.Data(ntfsBb.boot_code, out _);
|
|
||||||
sb.AppendLine("Volume is bootable");
|
sb.AppendLine("Volume is bootable");
|
||||||
sb.AppendFormat("Boot code's SHA1: {0}", bootChk).AppendLine();
|
sb.AppendFormat("Boot code's SHA1: {0}", bootChk).AppendLine();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,8 +43,7 @@ namespace DiscImageChef.Tests.Checksums
|
|||||||
[Test]
|
[Test]
|
||||||
public void Md5EmptyFile()
|
public void Md5EmptyFile()
|
||||||
{
|
{
|
||||||
Md5Context ctx = new Md5Context();
|
byte[] result = Md5Context.File(Path.Combine(Consts.TestFilesRoot, "checksums", "empty"));
|
||||||
byte[] result = ctx.File(Path.Combine(Consts.TestFilesRoot, "checksums", "empty"));
|
|
||||||
Assert.AreEqual(ExpectedEmpty, result);
|
Assert.AreEqual(ExpectedEmpty, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -57,8 +56,7 @@ namespace DiscImageChef.Tests.Checksums
|
|||||||
fs.Read(data, 0, 1048576);
|
fs.Read(data, 0, 1048576);
|
||||||
fs.Close();
|
fs.Close();
|
||||||
fs.Dispose();
|
fs.Dispose();
|
||||||
Md5Context ctx = new Md5Context();
|
Md5Context.Data(data, out byte[] result);
|
||||||
ctx.Data(data, out byte[] result);
|
|
||||||
Assert.AreEqual(ExpectedEmpty, result);
|
Assert.AreEqual(ExpectedEmpty, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -80,8 +78,7 @@ namespace DiscImageChef.Tests.Checksums
|
|||||||
[Test]
|
[Test]
|
||||||
public void Md5RandomFile()
|
public void Md5RandomFile()
|
||||||
{
|
{
|
||||||
Md5Context ctx = new Md5Context();
|
byte[] result = Md5Context.File(Path.Combine(Consts.TestFilesRoot, "checksums", "random"));
|
||||||
byte[] result = ctx.File(Path.Combine(Consts.TestFilesRoot, "checksums", "random"));
|
|
||||||
Assert.AreEqual(ExpectedRandom, result);
|
Assert.AreEqual(ExpectedRandom, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -94,8 +91,7 @@ namespace DiscImageChef.Tests.Checksums
|
|||||||
fs.Read(data, 0, 1048576);
|
fs.Read(data, 0, 1048576);
|
||||||
fs.Close();
|
fs.Close();
|
||||||
fs.Dispose();
|
fs.Dispose();
|
||||||
Md5Context ctx = new Md5Context();
|
Md5Context.Data(data, out byte[] result);
|
||||||
ctx.Data(data, out byte[] result);
|
|
||||||
Assert.AreEqual(ExpectedRandom, result);
|
Assert.AreEqual(ExpectedRandom, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -49,8 +49,7 @@ namespace DiscImageChef.Tests.Checksums
|
|||||||
[Test]
|
[Test]
|
||||||
public void Ripemd160EmptyFile()
|
public void Ripemd160EmptyFile()
|
||||||
{
|
{
|
||||||
Ripemd160Context ctx = new Ripemd160Context();
|
byte[] result = Ripemd160Context.File(Path.Combine(Consts.TestFilesRoot, "checksums", "empty"));
|
||||||
byte[] result = ctx.File(Path.Combine(Consts.TestFilesRoot, "checksums", "empty"));
|
|
||||||
Assert.AreEqual(ExpectedEmpty, result);
|
Assert.AreEqual(ExpectedEmpty, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -63,8 +62,7 @@ namespace DiscImageChef.Tests.Checksums
|
|||||||
fs.Read(data, 0, 1048576);
|
fs.Read(data, 0, 1048576);
|
||||||
fs.Close();
|
fs.Close();
|
||||||
fs.Dispose();
|
fs.Dispose();
|
||||||
Ripemd160Context ctx = new Ripemd160Context();
|
Ripemd160Context.Data(data, out byte[] result);
|
||||||
ctx.Data(data, out byte[] result);
|
|
||||||
Assert.AreEqual(ExpectedEmpty, result);
|
Assert.AreEqual(ExpectedEmpty, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -86,8 +84,7 @@ namespace DiscImageChef.Tests.Checksums
|
|||||||
[Test]
|
[Test]
|
||||||
public void Ripemd160RandomFile()
|
public void Ripemd160RandomFile()
|
||||||
{
|
{
|
||||||
Ripemd160Context ctx = new Ripemd160Context();
|
byte[] result = Ripemd160Context.File(Path.Combine(Consts.TestFilesRoot, "checksums", "random"));
|
||||||
byte[] result = ctx.File(Path.Combine(Consts.TestFilesRoot, "checksums", "random"));
|
|
||||||
Assert.AreEqual(ExpectedRandom, result);
|
Assert.AreEqual(ExpectedRandom, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -100,8 +97,7 @@ namespace DiscImageChef.Tests.Checksums
|
|||||||
fs.Read(data, 0, 1048576);
|
fs.Read(data, 0, 1048576);
|
||||||
fs.Close();
|
fs.Close();
|
||||||
fs.Dispose();
|
fs.Dispose();
|
||||||
Ripemd160Context ctx = new Ripemd160Context();
|
Ripemd160Context.Data(data, out byte[] result);
|
||||||
ctx.Data(data, out byte[] result);
|
|
||||||
Assert.AreEqual(ExpectedRandom, result);
|
Assert.AreEqual(ExpectedRandom, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -49,8 +49,7 @@ namespace DiscImageChef.Tests.Checksums
|
|||||||
[Test]
|
[Test]
|
||||||
public void Sha1EmptyFile()
|
public void Sha1EmptyFile()
|
||||||
{
|
{
|
||||||
Sha1Context ctx = new Sha1Context();
|
byte[] result = Sha1Context.File(Path.Combine(Consts.TestFilesRoot, "checksums", "empty"));
|
||||||
byte[] result = ctx.File(Path.Combine(Consts.TestFilesRoot, "checksums", "empty"));
|
|
||||||
Assert.AreEqual(ExpectedEmpty, result);
|
Assert.AreEqual(ExpectedEmpty, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -63,8 +62,7 @@ namespace DiscImageChef.Tests.Checksums
|
|||||||
fs.Read(data, 0, 1048576);
|
fs.Read(data, 0, 1048576);
|
||||||
fs.Close();
|
fs.Close();
|
||||||
fs.Dispose();
|
fs.Dispose();
|
||||||
Sha1Context ctx = new Sha1Context();
|
Sha1Context.Data(data, out byte[] result);
|
||||||
ctx.Data(data, out byte[] result);
|
|
||||||
Assert.AreEqual(ExpectedEmpty, result);
|
Assert.AreEqual(ExpectedEmpty, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -86,8 +84,7 @@ namespace DiscImageChef.Tests.Checksums
|
|||||||
[Test]
|
[Test]
|
||||||
public void Sha1RandomFile()
|
public void Sha1RandomFile()
|
||||||
{
|
{
|
||||||
Sha1Context ctx = new Sha1Context();
|
byte[] result = Sha1Context.File(Path.Combine(Consts.TestFilesRoot, "checksums", "random"));
|
||||||
byte[] result = ctx.File(Path.Combine(Consts.TestFilesRoot, "checksums", "random"));
|
|
||||||
Assert.AreEqual(ExpectedRandom, result);
|
Assert.AreEqual(ExpectedRandom, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -100,8 +97,7 @@ namespace DiscImageChef.Tests.Checksums
|
|||||||
fs.Read(data, 0, 1048576);
|
fs.Read(data, 0, 1048576);
|
||||||
fs.Close();
|
fs.Close();
|
||||||
fs.Dispose();
|
fs.Dispose();
|
||||||
Sha1Context ctx = new Sha1Context();
|
Sha1Context.Data(data, out byte[] result);
|
||||||
ctx.Data(data, out byte[] result);
|
|
||||||
Assert.AreEqual(ExpectedRandom, result);
|
Assert.AreEqual(ExpectedRandom, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -49,8 +49,7 @@ namespace DiscImageChef.Tests.Checksums
|
|||||||
[Test]
|
[Test]
|
||||||
public void Sha256EmptyFile()
|
public void Sha256EmptyFile()
|
||||||
{
|
{
|
||||||
Sha256Context ctx = new Sha256Context();
|
byte[] result = Sha256Context.File(Path.Combine(Consts.TestFilesRoot, "checksums", "empty"));
|
||||||
byte[] result = ctx.File(Path.Combine(Consts.TestFilesRoot, "checksums", "empty"));
|
|
||||||
Assert.AreEqual(ExpectedEmpty, result);
|
Assert.AreEqual(ExpectedEmpty, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -63,8 +62,7 @@ namespace DiscImageChef.Tests.Checksums
|
|||||||
fs.Read(data, 0, 1048576);
|
fs.Read(data, 0, 1048576);
|
||||||
fs.Close();
|
fs.Close();
|
||||||
fs.Dispose();
|
fs.Dispose();
|
||||||
Sha256Context ctx = new Sha256Context();
|
Sha256Context.Data(data, out byte[] result);
|
||||||
ctx.Data(data, out byte[] result);
|
|
||||||
Assert.AreEqual(ExpectedEmpty, result);
|
Assert.AreEqual(ExpectedEmpty, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -86,8 +84,7 @@ namespace DiscImageChef.Tests.Checksums
|
|||||||
[Test]
|
[Test]
|
||||||
public void Sha256RandomFile()
|
public void Sha256RandomFile()
|
||||||
{
|
{
|
||||||
Sha256Context ctx = new Sha256Context();
|
byte[] result = Sha256Context.File(Path.Combine(Consts.TestFilesRoot, "checksums", "random"));
|
||||||
byte[] result = ctx.File(Path.Combine(Consts.TestFilesRoot, "checksums", "random"));
|
|
||||||
Assert.AreEqual(ExpectedRandom, result);
|
Assert.AreEqual(ExpectedRandom, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -100,8 +97,7 @@ namespace DiscImageChef.Tests.Checksums
|
|||||||
fs.Read(data, 0, 1048576);
|
fs.Read(data, 0, 1048576);
|
||||||
fs.Close();
|
fs.Close();
|
||||||
fs.Dispose();
|
fs.Dispose();
|
||||||
Sha256Context ctx = new Sha256Context();
|
Sha256Context.Data(data, out byte[] result);
|
||||||
ctx.Data(data, out byte[] result);
|
|
||||||
Assert.AreEqual(ExpectedRandom, result);
|
Assert.AreEqual(ExpectedRandom, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -51,8 +51,7 @@ namespace DiscImageChef.Tests.Checksums
|
|||||||
[Test]
|
[Test]
|
||||||
public void Sha384EmptyFile()
|
public void Sha384EmptyFile()
|
||||||
{
|
{
|
||||||
Sha384Context ctx = new Sha384Context();
|
byte[] result = Sha384Context.File(Path.Combine(Consts.TestFilesRoot, "checksums", "empty"));
|
||||||
byte[] result = ctx.File(Path.Combine(Consts.TestFilesRoot, "checksums", "empty"));
|
|
||||||
Assert.AreEqual(ExpectedEmpty, result);
|
Assert.AreEqual(ExpectedEmpty, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -65,8 +64,7 @@ namespace DiscImageChef.Tests.Checksums
|
|||||||
fs.Read(data, 0, 1048576);
|
fs.Read(data, 0, 1048576);
|
||||||
fs.Close();
|
fs.Close();
|
||||||
fs.Dispose();
|
fs.Dispose();
|
||||||
Sha384Context ctx = new Sha384Context();
|
Sha384Context.Data(data, out byte[] result);
|
||||||
ctx.Data(data, out byte[] result);
|
|
||||||
Assert.AreEqual(ExpectedEmpty, result);
|
Assert.AreEqual(ExpectedEmpty, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -88,8 +86,7 @@ namespace DiscImageChef.Tests.Checksums
|
|||||||
[Test]
|
[Test]
|
||||||
public void Sha384RandomFile()
|
public void Sha384RandomFile()
|
||||||
{
|
{
|
||||||
Sha384Context ctx = new Sha384Context();
|
byte[] result = Sha384Context.File(Path.Combine(Consts.TestFilesRoot, "checksums", "random"));
|
||||||
byte[] result = ctx.File(Path.Combine(Consts.TestFilesRoot, "checksums", "random"));
|
|
||||||
Assert.AreEqual(ExpectedRandom, result);
|
Assert.AreEqual(ExpectedRandom, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -102,8 +99,7 @@ namespace DiscImageChef.Tests.Checksums
|
|||||||
fs.Read(data, 0, 1048576);
|
fs.Read(data, 0, 1048576);
|
||||||
fs.Close();
|
fs.Close();
|
||||||
fs.Dispose();
|
fs.Dispose();
|
||||||
Sha384Context ctx = new Sha384Context();
|
Sha384Context.Data(data, out byte[] result);
|
||||||
ctx.Data(data, out byte[] result);
|
|
||||||
Assert.AreEqual(ExpectedRandom, result);
|
Assert.AreEqual(ExpectedRandom, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -53,8 +53,7 @@ namespace DiscImageChef.Tests.Checksums
|
|||||||
[Test]
|
[Test]
|
||||||
public void Sha512EmptyFile()
|
public void Sha512EmptyFile()
|
||||||
{
|
{
|
||||||
Sha512Context ctx = new Sha512Context();
|
byte[] result = Sha512Context.File(Path.Combine(Consts.TestFilesRoot, "checksums", "empty"));
|
||||||
byte[] result = ctx.File(Path.Combine(Consts.TestFilesRoot, "checksums", "empty"));
|
|
||||||
Assert.AreEqual(ExpectedEmpty, result);
|
Assert.AreEqual(ExpectedEmpty, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,8 +66,7 @@ namespace DiscImageChef.Tests.Checksums
|
|||||||
fs.Read(data, 0, 1048576);
|
fs.Read(data, 0, 1048576);
|
||||||
fs.Close();
|
fs.Close();
|
||||||
fs.Dispose();
|
fs.Dispose();
|
||||||
Sha512Context ctx = new Sha512Context();
|
Sha512Context.Data(data, out byte[] result);
|
||||||
ctx.Data(data, out byte[] result);
|
|
||||||
Assert.AreEqual(ExpectedEmpty, result);
|
Assert.AreEqual(ExpectedEmpty, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -90,8 +88,7 @@ namespace DiscImageChef.Tests.Checksums
|
|||||||
[Test]
|
[Test]
|
||||||
public void Sha512RandomFile()
|
public void Sha512RandomFile()
|
||||||
{
|
{
|
||||||
Sha512Context ctx = new Sha512Context();
|
byte[] result = Sha512Context.File(Path.Combine(Consts.TestFilesRoot, "checksums", "random"));
|
||||||
byte[] result = ctx.File(Path.Combine(Consts.TestFilesRoot, "checksums", "random"));
|
|
||||||
Assert.AreEqual(ExpectedRandom, result);
|
Assert.AreEqual(ExpectedRandom, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -104,8 +101,7 @@ namespace DiscImageChef.Tests.Checksums
|
|||||||
fs.Read(data, 0, 1048576);
|
fs.Read(data, 0, 1048576);
|
||||||
fs.Close();
|
fs.Close();
|
||||||
fs.Dispose();
|
fs.Dispose();
|
||||||
Sha512Context ctx = new Sha512Context();
|
Sha512Context.Data(data, out byte[] result);
|
||||||
ctx.Data(data, out byte[] result);
|
|
||||||
Assert.AreEqual(ExpectedRandom, result);
|
Assert.AreEqual(ExpectedRandom, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -53,12 +53,10 @@ namespace DiscImageChef.Tests.Filters
|
|||||||
[Test]
|
[Test]
|
||||||
public void CheckCorrectFile()
|
public void CheckCorrectFile()
|
||||||
{
|
{
|
||||||
Md5Context ctx = new Md5Context();
|
string result = Md5Context.File(location, out _);
|
||||||
string result = ctx.File(location, out _);
|
|
||||||
Assert.AreEqual(EXPECTED_FILE, result);
|
Assert.AreEqual(EXPECTED_FILE, result);
|
||||||
|
|
||||||
ctx = new Md5Context();
|
result = Md5Context.File(sidecar, out _);
|
||||||
result = ctx.File(sidecar, out _);
|
|
||||||
Assert.AreEqual(EXPECTED_SIDECAR, result);
|
Assert.AreEqual(EXPECTED_SIDECAR, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -94,8 +92,7 @@ namespace DiscImageChef.Tests.Filters
|
|||||||
str.Close();
|
str.Close();
|
||||||
str.Dispose();
|
str.Dispose();
|
||||||
filter.Close();
|
filter.Close();
|
||||||
Md5Context ctx = new Md5Context();
|
string result = Md5Context.Data(data, out _);
|
||||||
string result = ctx.Data(data, out _);
|
|
||||||
Assert.AreEqual(EXPECTED_CONTENTS, result);
|
Assert.AreEqual(EXPECTED_CONTENTS, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -110,8 +107,7 @@ namespace DiscImageChef.Tests.Filters
|
|||||||
str.Close();
|
str.Close();
|
||||||
str.Dispose();
|
str.Dispose();
|
||||||
filter.Close();
|
filter.Close();
|
||||||
Md5Context ctx = new Md5Context();
|
string result = Md5Context.Data(data, out _);
|
||||||
string result = ctx.Data(data, out _);
|
|
||||||
Assert.AreEqual(EXPECTED_RESOURCE, result);
|
Assert.AreEqual(EXPECTED_RESOURCE, result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,12 +52,10 @@ namespace DiscImageChef.Tests.Filters
|
|||||||
[Test]
|
[Test]
|
||||||
public void CheckCorrectFile()
|
public void CheckCorrectFile()
|
||||||
{
|
{
|
||||||
Md5Context ctx = new Md5Context();
|
string result = Md5Context.File(location, out _);
|
||||||
string result = ctx.File(location, out _);
|
|
||||||
Assert.AreEqual(EXPECTED_FILE, result);
|
Assert.AreEqual(EXPECTED_FILE, result);
|
||||||
|
|
||||||
ctx = new Md5Context();
|
result = Md5Context.File(sidecar, out _);
|
||||||
result = ctx.File(sidecar, out _);
|
|
||||||
Assert.AreEqual(EXPECTED_SIDECAR, result);
|
Assert.AreEqual(EXPECTED_SIDECAR, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -93,8 +91,7 @@ namespace DiscImageChef.Tests.Filters
|
|||||||
str.Close();
|
str.Close();
|
||||||
str.Dispose();
|
str.Dispose();
|
||||||
filter.Close();
|
filter.Close();
|
||||||
Md5Context ctx = new Md5Context();
|
string result = Md5Context.Data(data, out _);
|
||||||
string result = ctx.Data(data, out _);
|
|
||||||
Assert.AreEqual(EXPECTED_CONTENTS, result);
|
Assert.AreEqual(EXPECTED_CONTENTS, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -109,8 +106,7 @@ namespace DiscImageChef.Tests.Filters
|
|||||||
str.Close();
|
str.Close();
|
||||||
str.Dispose();
|
str.Dispose();
|
||||||
filter.Close();
|
filter.Close();
|
||||||
Md5Context ctx = new Md5Context();
|
string result = Md5Context.Data(data, out _);
|
||||||
string result = ctx.Data(data, out _);
|
|
||||||
Assert.AreEqual(EXPECTED_RESOURCE, result);
|
Assert.AreEqual(EXPECTED_RESOURCE, result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,12 +53,10 @@ namespace DiscImageChef.Tests.Filters
|
|||||||
[Test]
|
[Test]
|
||||||
public void CheckCorrectFile()
|
public void CheckCorrectFile()
|
||||||
{
|
{
|
||||||
Md5Context ctx = new Md5Context();
|
string result = Md5Context.File(location, out _);
|
||||||
string result = ctx.File(location, out _);
|
|
||||||
Assert.AreEqual(EXPECTED_FILE, result);
|
Assert.AreEqual(EXPECTED_FILE, result);
|
||||||
|
|
||||||
ctx = new Md5Context();
|
result = Md5Context.File(sidecar, out _);
|
||||||
result = ctx.File(sidecar, out _);
|
|
||||||
Assert.AreEqual(EXPECTED_SIDECAR, result);
|
Assert.AreEqual(EXPECTED_SIDECAR, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -94,8 +92,7 @@ namespace DiscImageChef.Tests.Filters
|
|||||||
str.Close();
|
str.Close();
|
||||||
str.Dispose();
|
str.Dispose();
|
||||||
filter.Close();
|
filter.Close();
|
||||||
Md5Context ctx = new Md5Context();
|
string result = Md5Context.Data(data, out _);
|
||||||
string result = ctx.Data(data, out _);
|
|
||||||
Assert.AreEqual(EXPECTED_CONTENTS, result);
|
Assert.AreEqual(EXPECTED_CONTENTS, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -110,8 +107,7 @@ namespace DiscImageChef.Tests.Filters
|
|||||||
str.Close();
|
str.Close();
|
||||||
str.Dispose();
|
str.Dispose();
|
||||||
filter.Close();
|
filter.Close();
|
||||||
Md5Context ctx = new Md5Context();
|
string result = Md5Context.Data(data, out _);
|
||||||
string result = ctx.Data(data, out _);
|
|
||||||
Assert.AreEqual(EXPECTED_RESOURCE, result);
|
Assert.AreEqual(EXPECTED_RESOURCE, result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,11 +53,11 @@ namespace DiscImageChef.Tests.Filters
|
|||||||
public void CheckCorrectFile()
|
public void CheckCorrectFile()
|
||||||
{
|
{
|
||||||
Md5Context ctx = new Md5Context();
|
Md5Context ctx = new Md5Context();
|
||||||
string result = ctx.File(location, out _);
|
string result = Md5Context.File(location, out _);
|
||||||
Assert.AreEqual(EXPECTED_FILE, result);
|
Assert.AreEqual(EXPECTED_FILE, result);
|
||||||
|
|
||||||
ctx = new Md5Context();
|
ctx = new Md5Context();
|
||||||
result = ctx.File(sidecar, out _);
|
result = Md5Context.File(sidecar, out _);
|
||||||
Assert.AreEqual(EXPECTED_SIDECAR, result);
|
Assert.AreEqual(EXPECTED_SIDECAR, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -94,7 +94,7 @@ namespace DiscImageChef.Tests.Filters
|
|||||||
str.Dispose();
|
str.Dispose();
|
||||||
filter.Close();
|
filter.Close();
|
||||||
Md5Context ctx = new Md5Context();
|
Md5Context ctx = new Md5Context();
|
||||||
string result = ctx.Data(data, out _);
|
string result = Md5Context.Data(data, out _);
|
||||||
Assert.AreEqual(EXPECTED_CONTENTS, result);
|
Assert.AreEqual(EXPECTED_CONTENTS, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -110,7 +110,7 @@ namespace DiscImageChef.Tests.Filters
|
|||||||
str.Dispose();
|
str.Dispose();
|
||||||
filter.Close();
|
filter.Close();
|
||||||
Md5Context ctx = new Md5Context();
|
Md5Context ctx = new Md5Context();
|
||||||
string result = ctx.Data(data, out _);
|
string result = Md5Context.Data(data, out _);
|
||||||
Assert.AreEqual(EXPECTED_RESOURCE, result);
|
Assert.AreEqual(EXPECTED_RESOURCE, result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,12 +52,10 @@ namespace DiscImageChef.Tests.Filters
|
|||||||
[Test]
|
[Test]
|
||||||
public void CheckCorrectFile()
|
public void CheckCorrectFile()
|
||||||
{
|
{
|
||||||
Md5Context ctx = new Md5Context();
|
string result = Md5Context.File(location, out _);
|
||||||
string result = ctx.File(location, out _);
|
|
||||||
Assert.AreEqual(EXPECTED_FILE, result);
|
Assert.AreEqual(EXPECTED_FILE, result);
|
||||||
|
|
||||||
ctx = new Md5Context();
|
result = Md5Context.File(sidecar, out _);
|
||||||
result = ctx.File(sidecar, out _);
|
|
||||||
Assert.AreEqual(EXPECTED_SIDECAR, result);
|
Assert.AreEqual(EXPECTED_SIDECAR, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -93,8 +91,7 @@ namespace DiscImageChef.Tests.Filters
|
|||||||
str.Close();
|
str.Close();
|
||||||
str.Dispose();
|
str.Dispose();
|
||||||
filter.Close();
|
filter.Close();
|
||||||
Md5Context ctx = new Md5Context();
|
string result = Md5Context.Data(data, out _);
|
||||||
string result = ctx.Data(data, out _);
|
|
||||||
Assert.AreEqual(EXPECTED_CONTENTS, result);
|
Assert.AreEqual(EXPECTED_CONTENTS, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -109,8 +106,7 @@ namespace DiscImageChef.Tests.Filters
|
|||||||
str.Close();
|
str.Close();
|
||||||
str.Dispose();
|
str.Dispose();
|
||||||
filter.Close();
|
filter.Close();
|
||||||
Md5Context ctx = new Md5Context();
|
string result = Md5Context.Data(data, out _);
|
||||||
string result = ctx.Data(data, out _);
|
|
||||||
Assert.AreEqual(EXPECTED_RESOURCE, result);
|
Assert.AreEqual(EXPECTED_RESOURCE, result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,12 +52,10 @@ namespace DiscImageChef.Tests.Filters
|
|||||||
[Test]
|
[Test]
|
||||||
public void CheckCorrectFile()
|
public void CheckCorrectFile()
|
||||||
{
|
{
|
||||||
Md5Context ctx = new Md5Context();
|
string result = Md5Context.File(location, out _);
|
||||||
string result = ctx.File(location, out _);
|
|
||||||
Assert.AreEqual(EXPECTED_FILE, result);
|
Assert.AreEqual(EXPECTED_FILE, result);
|
||||||
|
|
||||||
ctx = new Md5Context();
|
result = Md5Context.File(sidecar, out _);
|
||||||
result = ctx.File(sidecar, out _);
|
|
||||||
Assert.AreEqual(EXPECTED_SIDECAR, result);
|
Assert.AreEqual(EXPECTED_SIDECAR, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -93,8 +91,7 @@ namespace DiscImageChef.Tests.Filters
|
|||||||
str.Close();
|
str.Close();
|
||||||
str.Dispose();
|
str.Dispose();
|
||||||
filter.Close();
|
filter.Close();
|
||||||
Md5Context ctx = new Md5Context();
|
string result = Md5Context.Data(data, out _);
|
||||||
string result = ctx.Data(data, out _);
|
|
||||||
Assert.AreEqual(EXPECTED_CONTENTS, result);
|
Assert.AreEqual(EXPECTED_CONTENTS, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -109,8 +106,7 @@ namespace DiscImageChef.Tests.Filters
|
|||||||
str.Close();
|
str.Close();
|
||||||
str.Dispose();
|
str.Dispose();
|
||||||
filter.Close();
|
filter.Close();
|
||||||
Md5Context ctx = new Md5Context();
|
string result = Md5Context.Data(data, out _);
|
||||||
string result = ctx.Data(data, out _);
|
|
||||||
Assert.AreEqual(EXPECTED_RESOURCE, result);
|
Assert.AreEqual(EXPECTED_RESOURCE, result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,12 +52,10 @@ namespace DiscImageChef.Tests.Filters
|
|||||||
[Test]
|
[Test]
|
||||||
public void CheckCorrectFile()
|
public void CheckCorrectFile()
|
||||||
{
|
{
|
||||||
Md5Context ctx = new Md5Context();
|
string result = Md5Context.File(location, out _);
|
||||||
string result = ctx.File(location, out _);
|
|
||||||
Assert.AreEqual(EXPECTED_FILE, result);
|
Assert.AreEqual(EXPECTED_FILE, result);
|
||||||
|
|
||||||
ctx = new Md5Context();
|
result = Md5Context.File(sidecar, out _);
|
||||||
result = ctx.File(sidecar, out _);
|
|
||||||
Assert.AreEqual(EXPECTED_SIDECAR, result);
|
Assert.AreEqual(EXPECTED_SIDECAR, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -93,8 +91,7 @@ namespace DiscImageChef.Tests.Filters
|
|||||||
str.Close();
|
str.Close();
|
||||||
str.Dispose();
|
str.Dispose();
|
||||||
filter.Close();
|
filter.Close();
|
||||||
Md5Context ctx = new Md5Context();
|
string result = Md5Context.Data(data, out _);
|
||||||
string result = ctx.Data(data, out _);
|
|
||||||
Assert.AreEqual(EXPECTED_CONTENTS, result);
|
Assert.AreEqual(EXPECTED_CONTENTS, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -109,8 +106,7 @@ namespace DiscImageChef.Tests.Filters
|
|||||||
str.Close();
|
str.Close();
|
||||||
str.Dispose();
|
str.Dispose();
|
||||||
filter.Close();
|
filter.Close();
|
||||||
Md5Context ctx = new Md5Context();
|
string result = Md5Context.Data(data, out _);
|
||||||
string result = ctx.Data(data, out _);
|
|
||||||
Assert.AreEqual(EXPECTED_RESOURCE, result);
|
Assert.AreEqual(EXPECTED_RESOURCE, result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,8 +49,7 @@ namespace DiscImageChef.Tests.Filters
|
|||||||
[Test]
|
[Test]
|
||||||
public void CheckCorrectFile()
|
public void CheckCorrectFile()
|
||||||
{
|
{
|
||||||
Md5Context ctx = new Md5Context();
|
string result = Md5Context.File(location, out _);
|
||||||
string result = ctx.File(location, out _);
|
|
||||||
Assert.AreEqual(EXPECTED_FILE, result);
|
Assert.AreEqual(EXPECTED_FILE, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -86,8 +85,7 @@ namespace DiscImageChef.Tests.Filters
|
|||||||
str.Close();
|
str.Close();
|
||||||
str.Dispose();
|
str.Dispose();
|
||||||
filter.Close();
|
filter.Close();
|
||||||
Md5Context ctx = new Md5Context();
|
string result = Md5Context.Data(data, out _);
|
||||||
string result = ctx.Data(data, out _);
|
|
||||||
Assert.AreEqual(EXPECTED_CONTENTS, result);
|
Assert.AreEqual(EXPECTED_CONTENTS, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -102,8 +100,7 @@ namespace DiscImageChef.Tests.Filters
|
|||||||
str.Close();
|
str.Close();
|
||||||
str.Dispose();
|
str.Dispose();
|
||||||
filter.Close();
|
filter.Close();
|
||||||
Md5Context ctx = new Md5Context();
|
string result = Md5Context.Data(data, out _);
|
||||||
string result = ctx.Data(data, out _);
|
|
||||||
Assert.AreEqual(EXPECTED_RESOURCE, result);
|
Assert.AreEqual(EXPECTED_RESOURCE, result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,8 +50,7 @@ namespace DiscImageChef.Tests.Filters
|
|||||||
[Test]
|
[Test]
|
||||||
public void CheckCorrectFile()
|
public void CheckCorrectFile()
|
||||||
{
|
{
|
||||||
Md5Context ctx = new Md5Context();
|
byte[] result = Md5Context.File(location);
|
||||||
byte[] result = ctx.File(location);
|
|
||||||
Assert.AreEqual(ExpectedFile, result);
|
Assert.AreEqual(ExpectedFile, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -87,8 +86,7 @@ namespace DiscImageChef.Tests.Filters
|
|||||||
str.Close();
|
str.Close();
|
||||||
str.Dispose();
|
str.Dispose();
|
||||||
filter.Close();
|
filter.Close();
|
||||||
Md5Context ctx = new Md5Context();
|
Md5Context.Data(data, out byte[] result);
|
||||||
ctx.Data(data, out byte[] result);
|
|
||||||
Assert.AreEqual(ExpectedContents, result);
|
Assert.AreEqual(ExpectedContents, result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,8 +50,7 @@ namespace DiscImageChef.Tests.Filters
|
|||||||
[Test]
|
[Test]
|
||||||
public void CheckCorrectFile()
|
public void CheckCorrectFile()
|
||||||
{
|
{
|
||||||
Md5Context ctx = new Md5Context();
|
byte[] result = Md5Context.File(location);
|
||||||
byte[] result = ctx.File(location);
|
|
||||||
Assert.AreEqual(ExpectedFile, result);
|
Assert.AreEqual(ExpectedFile, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -87,8 +86,7 @@ namespace DiscImageChef.Tests.Filters
|
|||||||
str.Close();
|
str.Close();
|
||||||
str.Dispose();
|
str.Dispose();
|
||||||
filter.Close();
|
filter.Close();
|
||||||
Md5Context ctx = new Md5Context();
|
Md5Context.Data(data, out byte[] result);
|
||||||
ctx.Data(data, out byte[] result);
|
|
||||||
Assert.AreEqual(ExpectedContents, result);
|
Assert.AreEqual(ExpectedContents, result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,8 +50,7 @@ namespace DiscImageChef.Tests.Filters
|
|||||||
[Test]
|
[Test]
|
||||||
public void CheckCorrectFile()
|
public void CheckCorrectFile()
|
||||||
{
|
{
|
||||||
Md5Context ctx = new Md5Context();
|
byte[] result = Md5Context.File(location);
|
||||||
byte[] result = ctx.File(location);
|
|
||||||
Assert.AreEqual(ExpectedFile, result);
|
Assert.AreEqual(ExpectedFile, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -87,8 +86,7 @@ namespace DiscImageChef.Tests.Filters
|
|||||||
str.Close();
|
str.Close();
|
||||||
str.Dispose();
|
str.Dispose();
|
||||||
filter.Close();
|
filter.Close();
|
||||||
Md5Context ctx = new Md5Context();
|
Md5Context.Data(data, out byte[] result);
|
||||||
ctx.Data(data, out byte[] result);
|
|
||||||
Assert.AreEqual(ExpectedContents, result);
|
Assert.AreEqual(ExpectedContents, result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,8 +49,7 @@ namespace DiscImageChef.Tests.Filters
|
|||||||
[Test]
|
[Test]
|
||||||
public void CheckCorrectFile()
|
public void CheckCorrectFile()
|
||||||
{
|
{
|
||||||
Md5Context ctx = new Md5Context();
|
string result = Md5Context.File(location, out _);
|
||||||
string result = ctx.File(location, out _);
|
|
||||||
Assert.AreEqual(EXPECTED_FILE, result);
|
Assert.AreEqual(EXPECTED_FILE, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -86,8 +85,7 @@ namespace DiscImageChef.Tests.Filters
|
|||||||
str.Close();
|
str.Close();
|
||||||
str.Dispose();
|
str.Dispose();
|
||||||
filter.Close();
|
filter.Close();
|
||||||
Md5Context ctx = new Md5Context();
|
string result = Md5Context.Data(data, out _);
|
||||||
string result = ctx.Data(data, out _);
|
|
||||||
Assert.AreEqual(EXPECTED_CONTENTS, result);
|
Assert.AreEqual(EXPECTED_CONTENTS, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -102,8 +100,7 @@ namespace DiscImageChef.Tests.Filters
|
|||||||
str.Close();
|
str.Close();
|
||||||
str.Dispose();
|
str.Dispose();
|
||||||
filter.Close();
|
filter.Close();
|
||||||
Md5Context ctx = new Md5Context();
|
string result = Md5Context.Data(data, out _);
|
||||||
string result = ctx.Data(data, out _);
|
|
||||||
Assert.AreEqual(EXPECTED_RESOURCE, result);
|
Assert.AreEqual(EXPECTED_RESOURCE, result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,8 +49,7 @@ namespace DiscImageChef.Tests.Filters
|
|||||||
[Test]
|
[Test]
|
||||||
public void CheckCorrectFile()
|
public void CheckCorrectFile()
|
||||||
{
|
{
|
||||||
Md5Context ctx = new Md5Context();
|
string result = Md5Context.File(location, out _);
|
||||||
string result = ctx.File(location, out _);
|
|
||||||
Assert.AreEqual(EXPECTED_FILE, result);
|
Assert.AreEqual(EXPECTED_FILE, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -86,8 +85,7 @@ namespace DiscImageChef.Tests.Filters
|
|||||||
str.Close();
|
str.Close();
|
||||||
str.Dispose();
|
str.Dispose();
|
||||||
filter.Close();
|
filter.Close();
|
||||||
Md5Context ctx = new Md5Context();
|
string result = Md5Context.Data(data, out _);
|
||||||
string result = ctx.Data(data, out _);
|
|
||||||
Assert.AreEqual(EXPECTED_CONTENTS, result);
|
Assert.AreEqual(EXPECTED_CONTENTS, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -102,8 +100,7 @@ namespace DiscImageChef.Tests.Filters
|
|||||||
str.Close();
|
str.Close();
|
||||||
str.Dispose();
|
str.Dispose();
|
||||||
filter.Close();
|
filter.Close();
|
||||||
Md5Context ctx = new Md5Context();
|
string result = Md5Context.Data(data, out _);
|
||||||
string result = ctx.Data(data, out _);
|
|
||||||
Assert.AreEqual(EXPECTED_RESOURCE, result);
|
Assert.AreEqual(EXPECTED_RESOURCE, result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,8 +49,7 @@ namespace DiscImageChef.Tests.Filters
|
|||||||
[Test]
|
[Test]
|
||||||
public void CheckCorrectFile()
|
public void CheckCorrectFile()
|
||||||
{
|
{
|
||||||
Md5Context ctx = new Md5Context();
|
string result = Md5Context.File(location, out _);
|
||||||
string result = ctx.File(location, out _);
|
|
||||||
Assert.AreEqual(EXPECTED_FILE, result);
|
Assert.AreEqual(EXPECTED_FILE, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -86,8 +85,7 @@ namespace DiscImageChef.Tests.Filters
|
|||||||
str.Close();
|
str.Close();
|
||||||
str.Dispose();
|
str.Dispose();
|
||||||
filter.Close();
|
filter.Close();
|
||||||
Md5Context ctx = new Md5Context();
|
string result = Md5Context.Data(data, out _);
|
||||||
string result = ctx.Data(data, out _);
|
|
||||||
Assert.AreEqual(EXPECTED_CONTENTS, result);
|
Assert.AreEqual(EXPECTED_CONTENTS, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -102,8 +100,7 @@ namespace DiscImageChef.Tests.Filters
|
|||||||
str.Close();
|
str.Close();
|
||||||
str.Dispose();
|
str.Dispose();
|
||||||
filter.Close();
|
filter.Close();
|
||||||
Md5Context ctx = new Md5Context();
|
string result = Md5Context.Data(data, out _);
|
||||||
string result = ctx.Data(data, out _);
|
|
||||||
Assert.AreEqual(EXPECTED_RESOURCE, result);
|
Assert.AreEqual(EXPECTED_RESOURCE, result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,8 +49,7 @@ namespace DiscImageChef.Tests.Filters
|
|||||||
[Test]
|
[Test]
|
||||||
public void CheckCorrectFile()
|
public void CheckCorrectFile()
|
||||||
{
|
{
|
||||||
Md5Context ctx = new Md5Context();
|
string result = Md5Context.File(Path.Combine(Consts.TestFilesRoot, "filters", "pcexchange", "FINDER.DAT"),
|
||||||
string result = ctx.File(Path.Combine(Consts.TestFilesRoot, "filters", "pcexchange", "FINDER.DAT"),
|
|
||||||
out _);
|
out _);
|
||||||
Assert.AreEqual(EXPECTED_FILE, result);
|
Assert.AreEqual(EXPECTED_FILE, result);
|
||||||
}
|
}
|
||||||
@@ -87,8 +86,7 @@ namespace DiscImageChef.Tests.Filters
|
|||||||
str.Close();
|
str.Close();
|
||||||
str.Dispose();
|
str.Dispose();
|
||||||
filter.Close();
|
filter.Close();
|
||||||
Md5Context ctx = new Md5Context();
|
string result = Md5Context.Data(data, out _);
|
||||||
string result = ctx.Data(data, out _);
|
|
||||||
Assert.AreEqual(EXPECTED_CONTENTS, result);
|
Assert.AreEqual(EXPECTED_CONTENTS, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -103,8 +101,7 @@ namespace DiscImageChef.Tests.Filters
|
|||||||
str.Close();
|
str.Close();
|
||||||
str.Dispose();
|
str.Dispose();
|
||||||
filter.Close();
|
filter.Close();
|
||||||
Md5Context ctx = new Md5Context();
|
string result = Md5Context.Data(data, out _);
|
||||||
string result = ctx.Data(data, out _);
|
|
||||||
Assert.AreEqual(EXPECTED_RESOURCE, result);
|
Assert.AreEqual(EXPECTED_RESOURCE, result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,8 +50,7 @@ namespace DiscImageChef.Tests.Filters
|
|||||||
[Test]
|
[Test]
|
||||||
public void CheckCorrectFile()
|
public void CheckCorrectFile()
|
||||||
{
|
{
|
||||||
Md5Context ctx = new Md5Context();
|
byte[] result = Md5Context.File(location);
|
||||||
byte[] result = ctx.File(location);
|
|
||||||
Assert.AreEqual(ExpectedFile, result);
|
Assert.AreEqual(ExpectedFile, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -87,8 +86,7 @@ namespace DiscImageChef.Tests.Filters
|
|||||||
str.Close();
|
str.Close();
|
||||||
str.Dispose();
|
str.Dispose();
|
||||||
filter.Close();
|
filter.Close();
|
||||||
Md5Context ctx = new Md5Context();
|
Md5Context.Data(data, out byte[] result);
|
||||||
ctx.Data(data, out byte[] result);
|
|
||||||
Assert.AreEqual(ExpectedContents, result);
|
Assert.AreEqual(ExpectedContents, result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -84,7 +84,6 @@ namespace DiscImageChef.Commands
|
|||||||
|
|
||||||
foreach(Track currentTrack in inputTracks)
|
foreach(Track currentTrack in inputTracks)
|
||||||
{
|
{
|
||||||
Sha1Context sha1CtxTrack = new Sha1Context();
|
|
||||||
entTable = new ulong[256];
|
entTable = new ulong[256];
|
||||||
ulong trackSize = 0;
|
ulong trackSize = 0;
|
||||||
List<string> uniqueSectorsPerTrack = new List<string>();
|
List<string> uniqueSectorsPerTrack = new List<string>();
|
||||||
@@ -99,7 +98,7 @@ namespace DiscImageChef.Commands
|
|||||||
|
|
||||||
if(options.DuplicatedSectors)
|
if(options.DuplicatedSectors)
|
||||||
{
|
{
|
||||||
string sectorHash = sha1CtxTrack.Data(sector, out _);
|
string sectorHash = Sha1Context.Data(sector, out _);
|
||||||
if(!uniqueSectorsPerTrack.Contains(sectorHash)) uniqueSectorsPerTrack.Add(sectorHash);
|
if(!uniqueSectorsPerTrack.Contains(sectorHash)) uniqueSectorsPerTrack.Add(sectorHash);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -129,7 +128,6 @@ namespace DiscImageChef.Commands
|
|||||||
|
|
||||||
if(!options.WholeDisc) return;
|
if(!options.WholeDisc) return;
|
||||||
|
|
||||||
Sha1Context sha1Ctx = new Sha1Context();
|
|
||||||
entTable = new ulong[256];
|
entTable = new ulong[256];
|
||||||
ulong diskSize = 0;
|
ulong diskSize = 0;
|
||||||
List<string> uniqueSectors = new List<string>();
|
List<string> uniqueSectors = new List<string>();
|
||||||
@@ -144,7 +142,7 @@ namespace DiscImageChef.Commands
|
|||||||
|
|
||||||
if(options.DuplicatedSectors)
|
if(options.DuplicatedSectors)
|
||||||
{
|
{
|
||||||
string sectorHash = sha1Ctx.Data(sector, out _);
|
string sectorHash = Sha1Context.Data(sector, out _);
|
||||||
if(!uniqueSectors.Contains(sectorHash)) uniqueSectors.Add(sectorHash);
|
if(!uniqueSectors.Contains(sectorHash)) uniqueSectors.Add(sectorHash);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user