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)
|
||||
{
|
||||
FileStream fileStream = new FileStream(filename, FileMode.Open);
|
||||
ushort localSum1, localSum2;
|
||||
uint finalSum;
|
||||
|
||||
localSum1 = 1;
|
||||
localSum2 = 0;
|
||||
ushort localSum1 = 1;
|
||||
ushort localSum2 = 0;
|
||||
|
||||
for(int i = 0; i < fileStream.Length; i++)
|
||||
{
|
||||
@@ -131,7 +129,7 @@ namespace DiscImageChef.Checksums
|
||||
localSum2 = (ushort)((localSum2 + localSum1) % ADLER_MODULE);
|
||||
}
|
||||
|
||||
finalSum = (uint)((localSum2 << 16) | localSum1);
|
||||
uint finalSum = (uint)((localSum2 << 16) | localSum1);
|
||||
|
||||
BigEndianBitConverter.IsLittleEndian = BitConverter.IsLittleEndian;
|
||||
hash = BigEndianBitConverter.GetBytes(finalSum);
|
||||
@@ -153,11 +151,8 @@ namespace DiscImageChef.Checksums
|
||||
/// <param name="hash">Byte array of the hash value.</param>
|
||||
public static string Data(byte[] data, uint len, out byte[] hash)
|
||||
{
|
||||
ushort localSum1, localSum2;
|
||||
uint finalSum;
|
||||
|
||||
localSum1 = 1;
|
||||
localSum2 = 0;
|
||||
ushort localSum1 = 1;
|
||||
ushort localSum2 = 0;
|
||||
|
||||
for(int i = 0; i < len; i++)
|
||||
{
|
||||
@@ -165,7 +160,7 @@ namespace DiscImageChef.Checksums
|
||||
localSum2 = (ushort)((localSum2 + localSum1) % ADLER_MODULE);
|
||||
}
|
||||
|
||||
finalSum = (uint)((localSum2 << 16) | localSum1);
|
||||
uint finalSum = (uint)((localSum2 << 16) | localSum1);
|
||||
|
||||
BigEndianBitConverter.IsLittleEndian = BitConverter.IsLittleEndian;
|
||||
hash = BigEndianBitConverter.GetBytes(finalSum);
|
||||
|
||||
@@ -217,9 +217,7 @@ namespace DiscImageChef.Checksums
|
||||
/// <param name="seed">CRC seed</param>
|
||||
public static string Data(byte[] data, uint len, out byte[] hash, uint polynomial, uint seed)
|
||||
{
|
||||
uint localhashInt;
|
||||
|
||||
localhashInt = seed;
|
||||
uint localhashInt = seed;
|
||||
|
||||
uint[] localTable = new uint[256];
|
||||
for(int i = 0; i < 256; i++)
|
||||
|
||||
@@ -173,12 +173,11 @@ namespace DiscImageChef.Checksums
|
||||
public static string File(string filename, out byte[] hash)
|
||||
{
|
||||
FileStream fileStream = new FileStream(filename, FileMode.Open);
|
||||
ushort localSum1, localSum2, block;
|
||||
uint finalSum;
|
||||
ushort block;
|
||||
byte[] blockBytes;
|
||||
|
||||
localSum1 = 0xFFFF;
|
||||
localSum2 = 0xFFFF;
|
||||
ushort localSum1 = 0xFFFF;
|
||||
ushort localSum2 = 0xFFFF;
|
||||
|
||||
if(fileStream.Length % 2 == 0)
|
||||
for(int i = 0; i < fileStream.Length; i += 2)
|
||||
@@ -209,7 +208,7 @@ namespace DiscImageChef.Checksums
|
||||
localSum2 = (ushort)((localSum2 + localSum1) % 0xFFFF);
|
||||
}
|
||||
|
||||
finalSum = (uint)(localSum1 + (localSum2 << 16));
|
||||
uint finalSum = (uint)(localSum1 + (localSum2 << 16));
|
||||
|
||||
hash = BitConverter.GetBytes(finalSum);
|
||||
|
||||
@@ -228,11 +227,10 @@ namespace DiscImageChef.Checksums
|
||||
/// <param name="hash">Byte array of the hash value.</param>
|
||||
public static string Data(byte[] data, uint len, out byte[] hash)
|
||||
{
|
||||
ushort localSum1, localSum2, block;
|
||||
uint finalSum;
|
||||
ushort block;
|
||||
|
||||
localSum1 = 0xFFFF;
|
||||
localSum2 = 0xFFFF;
|
||||
ushort localSum1 = 0xFFFF;
|
||||
ushort localSum2 = 0xFFFF;
|
||||
|
||||
if(len % 2 == 0)
|
||||
for(int i = 0; i < len; i += 2)
|
||||
@@ -259,7 +257,7 @@ namespace DiscImageChef.Checksums
|
||||
localSum2 = (ushort)((localSum2 + localSum1) % 0xFFFF);
|
||||
}
|
||||
|
||||
finalSum = (uint)(localSum1 + (localSum2 << 16));
|
||||
uint finalSum = (uint)(localSum1 + (localSum2 << 16));
|
||||
|
||||
hash = BitConverter.GetBytes(finalSum);
|
||||
|
||||
@@ -281,14 +279,14 @@ namespace DiscImageChef.Checksums
|
||||
}
|
||||
}
|
||||
|
||||
public class Fletcher16Context
|
||||
public class Fletcher16Context : IChecksum
|
||||
{
|
||||
byte sum1, sum2;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the Fletcher16 sums
|
||||
/// </summary>
|
||||
public void Init()
|
||||
public Fletcher16Context()
|
||||
{
|
||||
sum1 = 0xFF;
|
||||
sum2 = 0xFF;
|
||||
@@ -358,20 +356,18 @@ namespace DiscImageChef.Checksums
|
||||
public static string File(string filename, out byte[] hash)
|
||||
{
|
||||
FileStream fileStream = new FileStream(filename, FileMode.Open);
|
||||
byte localSum1, localSum2, block;
|
||||
ushort finalSum;
|
||||
|
||||
localSum1 = 0xFF;
|
||||
localSum2 = 0xFF;
|
||||
byte localSum1 = 0xFF;
|
||||
byte localSum2 = 0xFF;
|
||||
|
||||
for(int i = 0; i < fileStream.Length; i += 2)
|
||||
{
|
||||
block = (byte)fileStream.ReadByte();
|
||||
localSum1 = (byte)((localSum1 + block) % 0xFF);
|
||||
localSum2 = (byte)((localSum2 + localSum1) % 0xFF);
|
||||
byte block = (byte)fileStream.ReadByte();
|
||||
localSum1 = (byte)((localSum1 + block) % 0xFF);
|
||||
localSum2 = (byte)((localSum2 + localSum1) % 0xFF);
|
||||
}
|
||||
|
||||
finalSum = (ushort)(localSum1 + (localSum2 << 8));
|
||||
ushort finalSum = (ushort)(localSum1 + (localSum2 << 8));
|
||||
|
||||
hash = BitConverter.GetBytes(finalSum);
|
||||
|
||||
@@ -390,11 +386,8 @@ namespace DiscImageChef.Checksums
|
||||
/// <param name="hash">Byte array of the hash value.</param>
|
||||
public static string Data(byte[] data, uint len, out byte[] hash)
|
||||
{
|
||||
byte localSum1, localSum2;
|
||||
ushort finalSum;
|
||||
|
||||
localSum1 = 0xFF;
|
||||
localSum2 = 0xFF;
|
||||
byte localSum1 = 0xFF;
|
||||
byte localSum2 = 0xFF;
|
||||
|
||||
for(int i = 0; i < len; i++)
|
||||
{
|
||||
@@ -402,7 +395,7 @@ namespace DiscImageChef.Checksums
|
||||
localSum2 = (byte)((localSum2 + localSum1) % 0xFF);
|
||||
}
|
||||
|
||||
finalSum = (ushort)(localSum1 + (localSum2 << 8));
|
||||
ushort finalSum = (ushort)(localSum1 + (localSum2 << 8));
|
||||
|
||||
hash = BitConverter.GetBytes(finalSum);
|
||||
|
||||
|
||||
@@ -96,10 +96,11 @@ namespace DiscImageChef.Checksums
|
||||
/// Gets the hash of a file
|
||||
/// </summary>
|
||||
/// <param name="filename">File path.</param>
|
||||
public byte[] File(string filename)
|
||||
public static byte[] File(string filename)
|
||||
{
|
||||
FileStream fileStream = new FileStream(filename, FileMode.Open);
|
||||
byte[] result = md5Provider.ComputeHash(fileStream);
|
||||
MD5 localMd5Provider = MD5.Create();
|
||||
FileStream fileStream = new FileStream(filename, FileMode.Open);
|
||||
byte[] result = localMd5Provider.ComputeHash(fileStream);
|
||||
fileStream.Close();
|
||||
return result;
|
||||
}
|
||||
@@ -109,11 +110,12 @@ namespace DiscImageChef.Checksums
|
||||
/// </summary>
|
||||
/// <param name="filename">File path.</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)
|
||||
{
|
||||
FileStream fileStream = new FileStream(filename, FileMode.Open);
|
||||
hash = md5Provider.ComputeHash(fileStream);
|
||||
StringBuilder md5Output = new StringBuilder();
|
||||
MD5 localMd5Provider = MD5.Create();
|
||||
FileStream fileStream = new FileStream(filename, FileMode.Open);
|
||||
hash = localMd5Provider.ComputeHash(fileStream);
|
||||
StringBuilder md5Output = new StringBuilder();
|
||||
|
||||
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="len">Length of the data buffer to hash.</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();
|
||||
|
||||
foreach(byte h in hash) md5Output.Append(h.ToString("x2"));
|
||||
@@ -143,7 +146,7 @@ namespace DiscImageChef.Checksums
|
||||
/// </summary>
|
||||
/// <param name="data">Data buffer.</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);
|
||||
}
|
||||
|
||||
@@ -96,10 +96,11 @@ namespace DiscImageChef.Checksums
|
||||
/// Gets the hash of a file
|
||||
/// </summary>
|
||||
/// <param name="filename">File path.</param>
|
||||
public byte[] File(string filename)
|
||||
public static byte[] File(string filename)
|
||||
{
|
||||
FileStream fileStream = new FileStream(filename, FileMode.Open);
|
||||
byte[] result = ripemd160Provider.ComputeHash(fileStream);
|
||||
RIPEMD160 localRipemd160Provider = RIPEMD160.Create();
|
||||
FileStream fileStream = new FileStream(filename, FileMode.Open);
|
||||
byte[] result = localRipemd160Provider.ComputeHash(fileStream);
|
||||
fileStream.Close();
|
||||
return result;
|
||||
}
|
||||
@@ -109,11 +110,12 @@ namespace DiscImageChef.Checksums
|
||||
/// </summary>
|
||||
/// <param name="filename">File path.</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)
|
||||
{
|
||||
FileStream fileStream = new FileStream(filename, FileMode.Open);
|
||||
hash = ripemd160Provider.ComputeHash(fileStream);
|
||||
StringBuilder ripemd160Output = new StringBuilder();
|
||||
RIPEMD160 localRipemd160Provider = RIPEMD160.Create();
|
||||
FileStream fileStream = new FileStream(filename, FileMode.Open);
|
||||
hash = localRipemd160Provider.ComputeHash(fileStream);
|
||||
StringBuilder ripemd160Output = new StringBuilder();
|
||||
|
||||
foreach(byte h in hash) ripemd160Output.Append(h.ToString("x2"));
|
||||
|
||||
@@ -128,10 +130,11 @@ namespace DiscImageChef.Checksums
|
||||
/// <param name="data">Data buffer.</param>
|
||||
/// <param name="len">Length of the data buffer to hash.</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);
|
||||
StringBuilder ripemd160Output = new StringBuilder();
|
||||
RIPEMD160 localRipemd160Provider = RIPEMD160.Create();
|
||||
hash = localRipemd160Provider.ComputeHash(data, 0, (int)len);
|
||||
StringBuilder ripemd160Output = new StringBuilder();
|
||||
|
||||
foreach(byte h in hash) ripemd160Output.Append(h.ToString("x2"));
|
||||
|
||||
@@ -143,7 +146,7 @@ namespace DiscImageChef.Checksums
|
||||
/// </summary>
|
||||
/// <param name="data">Data buffer.</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);
|
||||
}
|
||||
|
||||
@@ -96,10 +96,11 @@ namespace DiscImageChef.Checksums
|
||||
/// Gets the hash of a file
|
||||
/// </summary>
|
||||
/// <param name="filename">File path.</param>
|
||||
public byte[] File(string filename)
|
||||
public static byte[] File(string filename)
|
||||
{
|
||||
FileStream fileStream = new FileStream(filename, FileMode.Open);
|
||||
byte[] result = sha1Provider.ComputeHash(fileStream);
|
||||
SHA1 localSha1Provider = SHA1.Create();
|
||||
FileStream fileStream = new FileStream(filename, FileMode.Open);
|
||||
byte[] result = localSha1Provider.ComputeHash(fileStream);
|
||||
fileStream.Close();
|
||||
return result;
|
||||
}
|
||||
@@ -109,11 +110,12 @@ namespace DiscImageChef.Checksums
|
||||
/// </summary>
|
||||
/// <param name="filename">File path.</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)
|
||||
{
|
||||
FileStream fileStream = new FileStream(filename, FileMode.Open);
|
||||
hash = sha1Provider.ComputeHash(fileStream);
|
||||
StringBuilder sha1Output = new StringBuilder();
|
||||
SHA1 localSha1Provider = SHA1.Create();
|
||||
FileStream fileStream = new FileStream(filename, FileMode.Open);
|
||||
hash = localSha1Provider.ComputeHash(fileStream);
|
||||
StringBuilder sha1Output = new StringBuilder();
|
||||
|
||||
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="len">Length of the data buffer to hash.</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();
|
||||
|
||||
foreach(byte h in hash) sha1Output.Append(h.ToString("x2"));
|
||||
@@ -143,7 +146,7 @@ namespace DiscImageChef.Checksums
|
||||
/// </summary>
|
||||
/// <param name="data">Data buffer.</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);
|
||||
}
|
||||
|
||||
@@ -96,10 +96,11 @@ namespace DiscImageChef.Checksums
|
||||
/// Gets the hash of a file
|
||||
/// </summary>
|
||||
/// <param name="filename">File path.</param>
|
||||
public byte[] File(string filename)
|
||||
public static byte[] File(string filename)
|
||||
{
|
||||
FileStream fileStream = new FileStream(filename, FileMode.Open);
|
||||
byte[] result = sha256Provider.ComputeHash(fileStream);
|
||||
SHA256 localSha256Provider = SHA256.Create();
|
||||
FileStream fileStream = new FileStream(filename, FileMode.Open);
|
||||
byte[] result = localSha256Provider.ComputeHash(fileStream);
|
||||
fileStream.Close();
|
||||
return result;
|
||||
}
|
||||
@@ -109,11 +110,12 @@ namespace DiscImageChef.Checksums
|
||||
/// </summary>
|
||||
/// <param name="filename">File path.</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)
|
||||
{
|
||||
FileStream fileStream = new FileStream(filename, FileMode.Open);
|
||||
hash = sha256Provider.ComputeHash(fileStream);
|
||||
StringBuilder sha256Output = new StringBuilder();
|
||||
SHA256 localSha256Provider = SHA256.Create();
|
||||
FileStream fileStream = new FileStream(filename, FileMode.Open);
|
||||
hash = localSha256Provider.ComputeHash(fileStream);
|
||||
StringBuilder sha256Output = new StringBuilder();
|
||||
|
||||
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="len">Length of the data buffer to hash.</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();
|
||||
|
||||
foreach(byte h in hash) sha256Output.Append(h.ToString("x2"));
|
||||
@@ -143,7 +146,7 @@ namespace DiscImageChef.Checksums
|
||||
/// </summary>
|
||||
/// <param name="data">Data buffer.</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);
|
||||
}
|
||||
|
||||
@@ -96,10 +96,11 @@ namespace DiscImageChef.Checksums
|
||||
/// Gets the hash of a file
|
||||
/// </summary>
|
||||
/// <param name="filename">File path.</param>
|
||||
public byte[] File(string filename)
|
||||
public static byte[] File(string filename)
|
||||
{
|
||||
FileStream fileStream = new FileStream(filename, FileMode.Open);
|
||||
byte[] result = sha384Provider.ComputeHash(fileStream);
|
||||
SHA384 localSha384Provider = SHA384.Create();
|
||||
FileStream fileStream = new FileStream(filename, FileMode.Open);
|
||||
byte[] result = localSha384Provider.ComputeHash(fileStream);
|
||||
fileStream.Close();
|
||||
return result;
|
||||
}
|
||||
@@ -109,11 +110,12 @@ namespace DiscImageChef.Checksums
|
||||
/// </summary>
|
||||
/// <param name="filename">File path.</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)
|
||||
{
|
||||
FileStream fileStream = new FileStream(filename, FileMode.Open);
|
||||
hash = sha384Provider.ComputeHash(fileStream);
|
||||
StringBuilder sha384Output = new StringBuilder();
|
||||
SHA384 localSha384Provider = SHA384.Create();
|
||||
FileStream fileStream = new FileStream(filename, FileMode.Open);
|
||||
hash = localSha384Provider.ComputeHash(fileStream);
|
||||
StringBuilder sha384Output = new StringBuilder();
|
||||
|
||||
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="len">Length of the data buffer to hash.</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();
|
||||
|
||||
foreach(byte h in hash) sha384Output.Append(h.ToString("x2"));
|
||||
@@ -143,7 +146,7 @@ namespace DiscImageChef.Checksums
|
||||
/// </summary>
|
||||
/// <param name="data">Data buffer.</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);
|
||||
}
|
||||
|
||||
@@ -96,10 +96,11 @@ namespace DiscImageChef.Checksums
|
||||
/// Gets the hash of a file
|
||||
/// </summary>
|
||||
/// <param name="filename">File path.</param>
|
||||
public byte[] File(string filename)
|
||||
public static byte[] File(string filename)
|
||||
{
|
||||
FileStream fileStream = new FileStream(filename, FileMode.Open);
|
||||
byte[] result = sha512Provider.ComputeHash(fileStream);
|
||||
SHA512 localSha512Provider = SHA512.Create();
|
||||
FileStream fileStream = new FileStream(filename, FileMode.Open);
|
||||
byte[] result = localSha512Provider.ComputeHash(fileStream);
|
||||
fileStream.Close();
|
||||
return result;
|
||||
}
|
||||
@@ -109,11 +110,12 @@ namespace DiscImageChef.Checksums
|
||||
/// </summary>
|
||||
/// <param name="filename">File path.</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)
|
||||
{
|
||||
FileStream fileStream = new FileStream(filename, FileMode.Open);
|
||||
hash = sha512Provider.ComputeHash(fileStream);
|
||||
StringBuilder sha512Output = new StringBuilder();
|
||||
SHA512 localSha512Provider = SHA512.Create();
|
||||
FileStream fileStream = new FileStream(filename, FileMode.Open);
|
||||
hash = localSha512Provider.ComputeHash(fileStream);
|
||||
StringBuilder sha512Output = new StringBuilder();
|
||||
|
||||
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="len">Length of the data buffer to hash.</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();
|
||||
|
||||
foreach(byte h in hash) sha512Output.Append(h.ToString("x2"));
|
||||
@@ -143,7 +146,7 @@ namespace DiscImageChef.Checksums
|
||||
/// </summary>
|
||||
/// <param name="data">Data buffer.</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);
|
||||
}
|
||||
|
||||
@@ -704,7 +704,6 @@ namespace DiscImageChef.Filesystems
|
||||
ulong rootDirectorySector = 0;
|
||||
string extraInfo = 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.
|
||||
uint sectorsPerRealSector;
|
||||
@@ -1036,9 +1035,9 @@ namespace DiscImageChef.Filesystems
|
||||
{
|
||||
XmlFsType.VolumeName = Encoding.ASCII.GetString(fat32Bpb.volume_label);
|
||||
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.
|
||||
// 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)
|
||||
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 "...
|
||||
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;
|
||||
byte[] bootCode = new byte[512 - sigSize - bpbSector[1] - 2];
|
||||
Array.Copy(bpbSector, bpbSector[1] + 2, bootCode, 0, bootCode.Length);
|
||||
sha1Ctx = new Sha1Context();
|
||||
sha1Ctx.Update(bootCode);
|
||||
bootChk = sha1Ctx.End();
|
||||
Sha1Context.Data(bootCode, out _);
|
||||
}
|
||||
// Intel big jump
|
||||
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];
|
||||
Array.Copy(bpbSector, BitConverter.ToUInt16(bpbSector, 1) + 3, bootCode, 0,
|
||||
bootCode.Length);
|
||||
sha1Ctx = new Sha1Context();
|
||||
sha1Ctx.Update(bootCode);
|
||||
bootChk = sha1Ctx.End();
|
||||
Sha1Context.Data(bootCode, out _);
|
||||
}
|
||||
|
||||
sb.AppendLine("Volume is bootable");
|
||||
|
||||
@@ -186,8 +186,7 @@ namespace DiscImageChef.Filesystems
|
||||
hpfsBpb.signature2 == 0xAA55)
|
||||
{
|
||||
XmlFsType.Bootable = true;
|
||||
Sha1Context sha1Ctx = new Sha1Context();
|
||||
string bootChk = sha1Ctx.Data(hpfsBpb.boot_code, out byte[] sha1_out);
|
||||
string bootChk = Sha1Context.Data(hpfsBpb.boot_code, out byte[] _);
|
||||
sb.AppendLine("Volume is bootable");
|
||||
sb.AppendFormat("Boot code's SHA1: {0}", bootChk).AppendLine();
|
||||
}
|
||||
|
||||
@@ -567,8 +567,7 @@ namespace DiscImageChef.Filesystems.ISO9660
|
||||
|
||||
if(torito != null)
|
||||
{
|
||||
vdSector = imagePlugin.ReadSector(torito.Value.catalog_sector + partition.Start);
|
||||
Sha1Context sha1Ctx = new Sha1Context();
|
||||
vdSector = imagePlugin.ReadSector(torito.Value.catalog_sector + partition.Start);
|
||||
|
||||
int toritoOff = 0;
|
||||
|
||||
@@ -642,7 +641,7 @@ namespace DiscImageChef.Filesystems.ISO9660
|
||||
|
||||
isoMetadata.AppendFormat("\tSystem type: 0x{0:X2}", initialEntry.system_type).AppendLine();
|
||||
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();
|
||||
}
|
||||
else isoMetadata.AppendLine("\tNot bootable");
|
||||
@@ -725,7 +724,7 @@ namespace DiscImageChef.Filesystems.ISO9660
|
||||
.AppendLine();
|
||||
if(bootImage != null)
|
||||
isoMetadata.AppendFormat("\t\tBootable image's SHA1: {0}",
|
||||
sha1Ctx.Data(bootImage, out _)).AppendLine();
|
||||
Sha1Context.Data(bootImage, out _)).AppendLine();
|
||||
}
|
||||
else isoMetadata.AppendLine("\t\tNot bootable");
|
||||
|
||||
|
||||
@@ -122,9 +122,8 @@ namespace DiscImageChef.Filesystems
|
||||
|
||||
if(ntfsBb.jump[0] == 0xEB && ntfsBb.jump[1] > 0x4E && ntfsBb.jump[1] < 0x80 && ntfsBb.signature2 == 0xAA55)
|
||||
{
|
||||
XmlFsType.Bootable = true;
|
||||
Sha1Context sha1Ctx = new Sha1Context();
|
||||
string bootChk = sha1Ctx.Data(ntfsBb.boot_code, out _);
|
||||
XmlFsType.Bootable = true;
|
||||
string bootChk = Sha1Context.Data(ntfsBb.boot_code, out _);
|
||||
sb.AppendLine("Volume is bootable");
|
||||
sb.AppendFormat("Boot code's SHA1: {0}", bootChk).AppendLine();
|
||||
}
|
||||
|
||||
@@ -43,8 +43,7 @@ namespace DiscImageChef.Tests.Checksums
|
||||
[Test]
|
||||
public void Md5EmptyFile()
|
||||
{
|
||||
Md5Context ctx = new Md5Context();
|
||||
byte[] result = ctx.File(Path.Combine(Consts.TestFilesRoot, "checksums", "empty"));
|
||||
byte[] result = Md5Context.File(Path.Combine(Consts.TestFilesRoot, "checksums", "empty"));
|
||||
Assert.AreEqual(ExpectedEmpty, result);
|
||||
}
|
||||
|
||||
@@ -57,8 +56,7 @@ namespace DiscImageChef.Tests.Checksums
|
||||
fs.Read(data, 0, 1048576);
|
||||
fs.Close();
|
||||
fs.Dispose();
|
||||
Md5Context ctx = new Md5Context();
|
||||
ctx.Data(data, out byte[] result);
|
||||
Md5Context.Data(data, out byte[] result);
|
||||
Assert.AreEqual(ExpectedEmpty, result);
|
||||
}
|
||||
|
||||
@@ -80,8 +78,7 @@ namespace DiscImageChef.Tests.Checksums
|
||||
[Test]
|
||||
public void Md5RandomFile()
|
||||
{
|
||||
Md5Context ctx = new Md5Context();
|
||||
byte[] result = ctx.File(Path.Combine(Consts.TestFilesRoot, "checksums", "random"));
|
||||
byte[] result = Md5Context.File(Path.Combine(Consts.TestFilesRoot, "checksums", "random"));
|
||||
Assert.AreEqual(ExpectedRandom, result);
|
||||
}
|
||||
|
||||
@@ -94,8 +91,7 @@ namespace DiscImageChef.Tests.Checksums
|
||||
fs.Read(data, 0, 1048576);
|
||||
fs.Close();
|
||||
fs.Dispose();
|
||||
Md5Context ctx = new Md5Context();
|
||||
ctx.Data(data, out byte[] result);
|
||||
Md5Context.Data(data, out byte[] result);
|
||||
Assert.AreEqual(ExpectedRandom, result);
|
||||
}
|
||||
|
||||
|
||||
@@ -49,8 +49,7 @@ namespace DiscImageChef.Tests.Checksums
|
||||
[Test]
|
||||
public void Ripemd160EmptyFile()
|
||||
{
|
||||
Ripemd160Context ctx = new Ripemd160Context();
|
||||
byte[] result = ctx.File(Path.Combine(Consts.TestFilesRoot, "checksums", "empty"));
|
||||
byte[] result = Ripemd160Context.File(Path.Combine(Consts.TestFilesRoot, "checksums", "empty"));
|
||||
Assert.AreEqual(ExpectedEmpty, result);
|
||||
}
|
||||
|
||||
@@ -63,8 +62,7 @@ namespace DiscImageChef.Tests.Checksums
|
||||
fs.Read(data, 0, 1048576);
|
||||
fs.Close();
|
||||
fs.Dispose();
|
||||
Ripemd160Context ctx = new Ripemd160Context();
|
||||
ctx.Data(data, out byte[] result);
|
||||
Ripemd160Context.Data(data, out byte[] result);
|
||||
Assert.AreEqual(ExpectedEmpty, result);
|
||||
}
|
||||
|
||||
@@ -86,8 +84,7 @@ namespace DiscImageChef.Tests.Checksums
|
||||
[Test]
|
||||
public void Ripemd160RandomFile()
|
||||
{
|
||||
Ripemd160Context ctx = new Ripemd160Context();
|
||||
byte[] result = ctx.File(Path.Combine(Consts.TestFilesRoot, "checksums", "random"));
|
||||
byte[] result = Ripemd160Context.File(Path.Combine(Consts.TestFilesRoot, "checksums", "random"));
|
||||
Assert.AreEqual(ExpectedRandom, result);
|
||||
}
|
||||
|
||||
@@ -100,8 +97,7 @@ namespace DiscImageChef.Tests.Checksums
|
||||
fs.Read(data, 0, 1048576);
|
||||
fs.Close();
|
||||
fs.Dispose();
|
||||
Ripemd160Context ctx = new Ripemd160Context();
|
||||
ctx.Data(data, out byte[] result);
|
||||
Ripemd160Context.Data(data, out byte[] result);
|
||||
Assert.AreEqual(ExpectedRandom, result);
|
||||
}
|
||||
|
||||
|
||||
@@ -49,8 +49,7 @@ namespace DiscImageChef.Tests.Checksums
|
||||
[Test]
|
||||
public void Sha1EmptyFile()
|
||||
{
|
||||
Sha1Context ctx = new Sha1Context();
|
||||
byte[] result = ctx.File(Path.Combine(Consts.TestFilesRoot, "checksums", "empty"));
|
||||
byte[] result = Sha1Context.File(Path.Combine(Consts.TestFilesRoot, "checksums", "empty"));
|
||||
Assert.AreEqual(ExpectedEmpty, result);
|
||||
}
|
||||
|
||||
@@ -63,8 +62,7 @@ namespace DiscImageChef.Tests.Checksums
|
||||
fs.Read(data, 0, 1048576);
|
||||
fs.Close();
|
||||
fs.Dispose();
|
||||
Sha1Context ctx = new Sha1Context();
|
||||
ctx.Data(data, out byte[] result);
|
||||
Sha1Context.Data(data, out byte[] result);
|
||||
Assert.AreEqual(ExpectedEmpty, result);
|
||||
}
|
||||
|
||||
@@ -86,8 +84,7 @@ namespace DiscImageChef.Tests.Checksums
|
||||
[Test]
|
||||
public void Sha1RandomFile()
|
||||
{
|
||||
Sha1Context ctx = new Sha1Context();
|
||||
byte[] result = ctx.File(Path.Combine(Consts.TestFilesRoot, "checksums", "random"));
|
||||
byte[] result = Sha1Context.File(Path.Combine(Consts.TestFilesRoot, "checksums", "random"));
|
||||
Assert.AreEqual(ExpectedRandom, result);
|
||||
}
|
||||
|
||||
@@ -100,8 +97,7 @@ namespace DiscImageChef.Tests.Checksums
|
||||
fs.Read(data, 0, 1048576);
|
||||
fs.Close();
|
||||
fs.Dispose();
|
||||
Sha1Context ctx = new Sha1Context();
|
||||
ctx.Data(data, out byte[] result);
|
||||
Sha1Context.Data(data, out byte[] result);
|
||||
Assert.AreEqual(ExpectedRandom, result);
|
||||
}
|
||||
|
||||
|
||||
@@ -49,8 +49,7 @@ namespace DiscImageChef.Tests.Checksums
|
||||
[Test]
|
||||
public void Sha256EmptyFile()
|
||||
{
|
||||
Sha256Context ctx = new Sha256Context();
|
||||
byte[] result = ctx.File(Path.Combine(Consts.TestFilesRoot, "checksums", "empty"));
|
||||
byte[] result = Sha256Context.File(Path.Combine(Consts.TestFilesRoot, "checksums", "empty"));
|
||||
Assert.AreEqual(ExpectedEmpty, result);
|
||||
}
|
||||
|
||||
@@ -63,8 +62,7 @@ namespace DiscImageChef.Tests.Checksums
|
||||
fs.Read(data, 0, 1048576);
|
||||
fs.Close();
|
||||
fs.Dispose();
|
||||
Sha256Context ctx = new Sha256Context();
|
||||
ctx.Data(data, out byte[] result);
|
||||
Sha256Context.Data(data, out byte[] result);
|
||||
Assert.AreEqual(ExpectedEmpty, result);
|
||||
}
|
||||
|
||||
@@ -86,8 +84,7 @@ namespace DiscImageChef.Tests.Checksums
|
||||
[Test]
|
||||
public void Sha256RandomFile()
|
||||
{
|
||||
Sha256Context ctx = new Sha256Context();
|
||||
byte[] result = ctx.File(Path.Combine(Consts.TestFilesRoot, "checksums", "random"));
|
||||
byte[] result = Sha256Context.File(Path.Combine(Consts.TestFilesRoot, "checksums", "random"));
|
||||
Assert.AreEqual(ExpectedRandom, result);
|
||||
}
|
||||
|
||||
@@ -100,8 +97,7 @@ namespace DiscImageChef.Tests.Checksums
|
||||
fs.Read(data, 0, 1048576);
|
||||
fs.Close();
|
||||
fs.Dispose();
|
||||
Sha256Context ctx = new Sha256Context();
|
||||
ctx.Data(data, out byte[] result);
|
||||
Sha256Context.Data(data, out byte[] result);
|
||||
Assert.AreEqual(ExpectedRandom, result);
|
||||
}
|
||||
|
||||
|
||||
@@ -51,8 +51,7 @@ namespace DiscImageChef.Tests.Checksums
|
||||
[Test]
|
||||
public void Sha384EmptyFile()
|
||||
{
|
||||
Sha384Context ctx = new Sha384Context();
|
||||
byte[] result = ctx.File(Path.Combine(Consts.TestFilesRoot, "checksums", "empty"));
|
||||
byte[] result = Sha384Context.File(Path.Combine(Consts.TestFilesRoot, "checksums", "empty"));
|
||||
Assert.AreEqual(ExpectedEmpty, result);
|
||||
}
|
||||
|
||||
@@ -65,8 +64,7 @@ namespace DiscImageChef.Tests.Checksums
|
||||
fs.Read(data, 0, 1048576);
|
||||
fs.Close();
|
||||
fs.Dispose();
|
||||
Sha384Context ctx = new Sha384Context();
|
||||
ctx.Data(data, out byte[] result);
|
||||
Sha384Context.Data(data, out byte[] result);
|
||||
Assert.AreEqual(ExpectedEmpty, result);
|
||||
}
|
||||
|
||||
@@ -88,8 +86,7 @@ namespace DiscImageChef.Tests.Checksums
|
||||
[Test]
|
||||
public void Sha384RandomFile()
|
||||
{
|
||||
Sha384Context ctx = new Sha384Context();
|
||||
byte[] result = ctx.File(Path.Combine(Consts.TestFilesRoot, "checksums", "random"));
|
||||
byte[] result = Sha384Context.File(Path.Combine(Consts.TestFilesRoot, "checksums", "random"));
|
||||
Assert.AreEqual(ExpectedRandom, result);
|
||||
}
|
||||
|
||||
@@ -102,8 +99,7 @@ namespace DiscImageChef.Tests.Checksums
|
||||
fs.Read(data, 0, 1048576);
|
||||
fs.Close();
|
||||
fs.Dispose();
|
||||
Sha384Context ctx = new Sha384Context();
|
||||
ctx.Data(data, out byte[] result);
|
||||
Sha384Context.Data(data, out byte[] result);
|
||||
Assert.AreEqual(ExpectedRandom, result);
|
||||
}
|
||||
|
||||
|
||||
@@ -53,8 +53,7 @@ namespace DiscImageChef.Tests.Checksums
|
||||
[Test]
|
||||
public void Sha512EmptyFile()
|
||||
{
|
||||
Sha512Context ctx = new Sha512Context();
|
||||
byte[] result = ctx.File(Path.Combine(Consts.TestFilesRoot, "checksums", "empty"));
|
||||
byte[] result = Sha512Context.File(Path.Combine(Consts.TestFilesRoot, "checksums", "empty"));
|
||||
Assert.AreEqual(ExpectedEmpty, result);
|
||||
}
|
||||
|
||||
@@ -67,8 +66,7 @@ namespace DiscImageChef.Tests.Checksums
|
||||
fs.Read(data, 0, 1048576);
|
||||
fs.Close();
|
||||
fs.Dispose();
|
||||
Sha512Context ctx = new Sha512Context();
|
||||
ctx.Data(data, out byte[] result);
|
||||
Sha512Context.Data(data, out byte[] result);
|
||||
Assert.AreEqual(ExpectedEmpty, result);
|
||||
}
|
||||
|
||||
@@ -90,8 +88,7 @@ namespace DiscImageChef.Tests.Checksums
|
||||
[Test]
|
||||
public void Sha512RandomFile()
|
||||
{
|
||||
Sha512Context ctx = new Sha512Context();
|
||||
byte[] result = ctx.File(Path.Combine(Consts.TestFilesRoot, "checksums", "random"));
|
||||
byte[] result = Sha512Context.File(Path.Combine(Consts.TestFilesRoot, "checksums", "random"));
|
||||
Assert.AreEqual(ExpectedRandom, result);
|
||||
}
|
||||
|
||||
@@ -104,8 +101,7 @@ namespace DiscImageChef.Tests.Checksums
|
||||
fs.Read(data, 0, 1048576);
|
||||
fs.Close();
|
||||
fs.Dispose();
|
||||
Sha512Context ctx = new Sha512Context();
|
||||
ctx.Data(data, out byte[] result);
|
||||
Sha512Context.Data(data, out byte[] result);
|
||||
Assert.AreEqual(ExpectedRandom, result);
|
||||
}
|
||||
|
||||
|
||||
@@ -53,12 +53,10 @@ namespace DiscImageChef.Tests.Filters
|
||||
[Test]
|
||||
public void CheckCorrectFile()
|
||||
{
|
||||
Md5Context ctx = new Md5Context();
|
||||
string result = ctx.File(location, out _);
|
||||
string result = Md5Context.File(location, out _);
|
||||
Assert.AreEqual(EXPECTED_FILE, result);
|
||||
|
||||
ctx = new Md5Context();
|
||||
result = ctx.File(sidecar, out _);
|
||||
result = Md5Context.File(sidecar, out _);
|
||||
Assert.AreEqual(EXPECTED_SIDECAR, result);
|
||||
}
|
||||
|
||||
@@ -94,8 +92,7 @@ namespace DiscImageChef.Tests.Filters
|
||||
str.Close();
|
||||
str.Dispose();
|
||||
filter.Close();
|
||||
Md5Context ctx = new Md5Context();
|
||||
string result = ctx.Data(data, out _);
|
||||
string result = Md5Context.Data(data, out _);
|
||||
Assert.AreEqual(EXPECTED_CONTENTS, result);
|
||||
}
|
||||
|
||||
@@ -110,8 +107,7 @@ namespace DiscImageChef.Tests.Filters
|
||||
str.Close();
|
||||
str.Dispose();
|
||||
filter.Close();
|
||||
Md5Context ctx = new Md5Context();
|
||||
string result = ctx.Data(data, out _);
|
||||
string result = Md5Context.Data(data, out _);
|
||||
Assert.AreEqual(EXPECTED_RESOURCE, result);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,12 +52,10 @@ namespace DiscImageChef.Tests.Filters
|
||||
[Test]
|
||||
public void CheckCorrectFile()
|
||||
{
|
||||
Md5Context ctx = new Md5Context();
|
||||
string result = ctx.File(location, out _);
|
||||
string result = Md5Context.File(location, out _);
|
||||
Assert.AreEqual(EXPECTED_FILE, result);
|
||||
|
||||
ctx = new Md5Context();
|
||||
result = ctx.File(sidecar, out _);
|
||||
result = Md5Context.File(sidecar, out _);
|
||||
Assert.AreEqual(EXPECTED_SIDECAR, result);
|
||||
}
|
||||
|
||||
@@ -93,8 +91,7 @@ namespace DiscImageChef.Tests.Filters
|
||||
str.Close();
|
||||
str.Dispose();
|
||||
filter.Close();
|
||||
Md5Context ctx = new Md5Context();
|
||||
string result = ctx.Data(data, out _);
|
||||
string result = Md5Context.Data(data, out _);
|
||||
Assert.AreEqual(EXPECTED_CONTENTS, result);
|
||||
}
|
||||
|
||||
@@ -109,8 +106,7 @@ namespace DiscImageChef.Tests.Filters
|
||||
str.Close();
|
||||
str.Dispose();
|
||||
filter.Close();
|
||||
Md5Context ctx = new Md5Context();
|
||||
string result = ctx.Data(data, out _);
|
||||
string result = Md5Context.Data(data, out _);
|
||||
Assert.AreEqual(EXPECTED_RESOURCE, result);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,12 +53,10 @@ namespace DiscImageChef.Tests.Filters
|
||||
[Test]
|
||||
public void CheckCorrectFile()
|
||||
{
|
||||
Md5Context ctx = new Md5Context();
|
||||
string result = ctx.File(location, out _);
|
||||
string result = Md5Context.File(location, out _);
|
||||
Assert.AreEqual(EXPECTED_FILE, result);
|
||||
|
||||
ctx = new Md5Context();
|
||||
result = ctx.File(sidecar, out _);
|
||||
result = Md5Context.File(sidecar, out _);
|
||||
Assert.AreEqual(EXPECTED_SIDECAR, result);
|
||||
}
|
||||
|
||||
@@ -94,8 +92,7 @@ namespace DiscImageChef.Tests.Filters
|
||||
str.Close();
|
||||
str.Dispose();
|
||||
filter.Close();
|
||||
Md5Context ctx = new Md5Context();
|
||||
string result = ctx.Data(data, out _);
|
||||
string result = Md5Context.Data(data, out _);
|
||||
Assert.AreEqual(EXPECTED_CONTENTS, result);
|
||||
}
|
||||
|
||||
@@ -110,8 +107,7 @@ namespace DiscImageChef.Tests.Filters
|
||||
str.Close();
|
||||
str.Dispose();
|
||||
filter.Close();
|
||||
Md5Context ctx = new Md5Context();
|
||||
string result = ctx.Data(data, out _);
|
||||
string result = Md5Context.Data(data, out _);
|
||||
Assert.AreEqual(EXPECTED_RESOURCE, result);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,11 +53,11 @@ namespace DiscImageChef.Tests.Filters
|
||||
public void CheckCorrectFile()
|
||||
{
|
||||
Md5Context ctx = new Md5Context();
|
||||
string result = ctx.File(location, out _);
|
||||
string result = Md5Context.File(location, out _);
|
||||
Assert.AreEqual(EXPECTED_FILE, result);
|
||||
|
||||
ctx = new Md5Context();
|
||||
result = ctx.File(sidecar, out _);
|
||||
result = Md5Context.File(sidecar, out _);
|
||||
Assert.AreEqual(EXPECTED_SIDECAR, result);
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ namespace DiscImageChef.Tests.Filters
|
||||
str.Dispose();
|
||||
filter.Close();
|
||||
Md5Context ctx = new Md5Context();
|
||||
string result = ctx.Data(data, out _);
|
||||
string result = Md5Context.Data(data, out _);
|
||||
Assert.AreEqual(EXPECTED_CONTENTS, result);
|
||||
}
|
||||
|
||||
@@ -110,7 +110,7 @@ namespace DiscImageChef.Tests.Filters
|
||||
str.Dispose();
|
||||
filter.Close();
|
||||
Md5Context ctx = new Md5Context();
|
||||
string result = ctx.Data(data, out _);
|
||||
string result = Md5Context.Data(data, out _);
|
||||
Assert.AreEqual(EXPECTED_RESOURCE, result);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,12 +52,10 @@ namespace DiscImageChef.Tests.Filters
|
||||
[Test]
|
||||
public void CheckCorrectFile()
|
||||
{
|
||||
Md5Context ctx = new Md5Context();
|
||||
string result = ctx.File(location, out _);
|
||||
string result = Md5Context.File(location, out _);
|
||||
Assert.AreEqual(EXPECTED_FILE, result);
|
||||
|
||||
ctx = new Md5Context();
|
||||
result = ctx.File(sidecar, out _);
|
||||
result = Md5Context.File(sidecar, out _);
|
||||
Assert.AreEqual(EXPECTED_SIDECAR, result);
|
||||
}
|
||||
|
||||
@@ -93,8 +91,7 @@ namespace DiscImageChef.Tests.Filters
|
||||
str.Close();
|
||||
str.Dispose();
|
||||
filter.Close();
|
||||
Md5Context ctx = new Md5Context();
|
||||
string result = ctx.Data(data, out _);
|
||||
string result = Md5Context.Data(data, out _);
|
||||
Assert.AreEqual(EXPECTED_CONTENTS, result);
|
||||
}
|
||||
|
||||
@@ -109,8 +106,7 @@ namespace DiscImageChef.Tests.Filters
|
||||
str.Close();
|
||||
str.Dispose();
|
||||
filter.Close();
|
||||
Md5Context ctx = new Md5Context();
|
||||
string result = ctx.Data(data, out _);
|
||||
string result = Md5Context.Data(data, out _);
|
||||
Assert.AreEqual(EXPECTED_RESOURCE, result);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,12 +52,10 @@ namespace DiscImageChef.Tests.Filters
|
||||
[Test]
|
||||
public void CheckCorrectFile()
|
||||
{
|
||||
Md5Context ctx = new Md5Context();
|
||||
string result = ctx.File(location, out _);
|
||||
string result = Md5Context.File(location, out _);
|
||||
Assert.AreEqual(EXPECTED_FILE, result);
|
||||
|
||||
ctx = new Md5Context();
|
||||
result = ctx.File(sidecar, out _);
|
||||
result = Md5Context.File(sidecar, out _);
|
||||
Assert.AreEqual(EXPECTED_SIDECAR, result);
|
||||
}
|
||||
|
||||
@@ -93,8 +91,7 @@ namespace DiscImageChef.Tests.Filters
|
||||
str.Close();
|
||||
str.Dispose();
|
||||
filter.Close();
|
||||
Md5Context ctx = new Md5Context();
|
||||
string result = ctx.Data(data, out _);
|
||||
string result = Md5Context.Data(data, out _);
|
||||
Assert.AreEqual(EXPECTED_CONTENTS, result);
|
||||
}
|
||||
|
||||
@@ -109,8 +106,7 @@ namespace DiscImageChef.Tests.Filters
|
||||
str.Close();
|
||||
str.Dispose();
|
||||
filter.Close();
|
||||
Md5Context ctx = new Md5Context();
|
||||
string result = ctx.Data(data, out _);
|
||||
string result = Md5Context.Data(data, out _);
|
||||
Assert.AreEqual(EXPECTED_RESOURCE, result);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,12 +52,10 @@ namespace DiscImageChef.Tests.Filters
|
||||
[Test]
|
||||
public void CheckCorrectFile()
|
||||
{
|
||||
Md5Context ctx = new Md5Context();
|
||||
string result = ctx.File(location, out _);
|
||||
string result = Md5Context.File(location, out _);
|
||||
Assert.AreEqual(EXPECTED_FILE, result);
|
||||
|
||||
ctx = new Md5Context();
|
||||
result = ctx.File(sidecar, out _);
|
||||
result = Md5Context.File(sidecar, out _);
|
||||
Assert.AreEqual(EXPECTED_SIDECAR, result);
|
||||
}
|
||||
|
||||
@@ -93,8 +91,7 @@ namespace DiscImageChef.Tests.Filters
|
||||
str.Close();
|
||||
str.Dispose();
|
||||
filter.Close();
|
||||
Md5Context ctx = new Md5Context();
|
||||
string result = ctx.Data(data, out _);
|
||||
string result = Md5Context.Data(data, out _);
|
||||
Assert.AreEqual(EXPECTED_CONTENTS, result);
|
||||
}
|
||||
|
||||
@@ -109,8 +106,7 @@ namespace DiscImageChef.Tests.Filters
|
||||
str.Close();
|
||||
str.Dispose();
|
||||
filter.Close();
|
||||
Md5Context ctx = new Md5Context();
|
||||
string result = ctx.Data(data, out _);
|
||||
string result = Md5Context.Data(data, out _);
|
||||
Assert.AreEqual(EXPECTED_RESOURCE, result);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,8 +49,7 @@ namespace DiscImageChef.Tests.Filters
|
||||
[Test]
|
||||
public void CheckCorrectFile()
|
||||
{
|
||||
Md5Context ctx = new Md5Context();
|
||||
string result = ctx.File(location, out _);
|
||||
string result = Md5Context.File(location, out _);
|
||||
Assert.AreEqual(EXPECTED_FILE, result);
|
||||
}
|
||||
|
||||
@@ -86,8 +85,7 @@ namespace DiscImageChef.Tests.Filters
|
||||
str.Close();
|
||||
str.Dispose();
|
||||
filter.Close();
|
||||
Md5Context ctx = new Md5Context();
|
||||
string result = ctx.Data(data, out _);
|
||||
string result = Md5Context.Data(data, out _);
|
||||
Assert.AreEqual(EXPECTED_CONTENTS, result);
|
||||
}
|
||||
|
||||
@@ -102,8 +100,7 @@ namespace DiscImageChef.Tests.Filters
|
||||
str.Close();
|
||||
str.Dispose();
|
||||
filter.Close();
|
||||
Md5Context ctx = new Md5Context();
|
||||
string result = ctx.Data(data, out _);
|
||||
string result = Md5Context.Data(data, out _);
|
||||
Assert.AreEqual(EXPECTED_RESOURCE, result);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,8 +50,7 @@ namespace DiscImageChef.Tests.Filters
|
||||
[Test]
|
||||
public void CheckCorrectFile()
|
||||
{
|
||||
Md5Context ctx = new Md5Context();
|
||||
byte[] result = ctx.File(location);
|
||||
byte[] result = Md5Context.File(location);
|
||||
Assert.AreEqual(ExpectedFile, result);
|
||||
}
|
||||
|
||||
@@ -87,8 +86,7 @@ namespace DiscImageChef.Tests.Filters
|
||||
str.Close();
|
||||
str.Dispose();
|
||||
filter.Close();
|
||||
Md5Context ctx = new Md5Context();
|
||||
ctx.Data(data, out byte[] result);
|
||||
Md5Context.Data(data, out byte[] result);
|
||||
Assert.AreEqual(ExpectedContents, result);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,8 +50,7 @@ namespace DiscImageChef.Tests.Filters
|
||||
[Test]
|
||||
public void CheckCorrectFile()
|
||||
{
|
||||
Md5Context ctx = new Md5Context();
|
||||
byte[] result = ctx.File(location);
|
||||
byte[] result = Md5Context.File(location);
|
||||
Assert.AreEqual(ExpectedFile, result);
|
||||
}
|
||||
|
||||
@@ -87,8 +86,7 @@ namespace DiscImageChef.Tests.Filters
|
||||
str.Close();
|
||||
str.Dispose();
|
||||
filter.Close();
|
||||
Md5Context ctx = new Md5Context();
|
||||
ctx.Data(data, out byte[] result);
|
||||
Md5Context.Data(data, out byte[] result);
|
||||
Assert.AreEqual(ExpectedContents, result);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,8 +50,7 @@ namespace DiscImageChef.Tests.Filters
|
||||
[Test]
|
||||
public void CheckCorrectFile()
|
||||
{
|
||||
Md5Context ctx = new Md5Context();
|
||||
byte[] result = ctx.File(location);
|
||||
byte[] result = Md5Context.File(location);
|
||||
Assert.AreEqual(ExpectedFile, result);
|
||||
}
|
||||
|
||||
@@ -87,8 +86,7 @@ namespace DiscImageChef.Tests.Filters
|
||||
str.Close();
|
||||
str.Dispose();
|
||||
filter.Close();
|
||||
Md5Context ctx = new Md5Context();
|
||||
ctx.Data(data, out byte[] result);
|
||||
Md5Context.Data(data, out byte[] result);
|
||||
Assert.AreEqual(ExpectedContents, result);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,8 +49,7 @@ namespace DiscImageChef.Tests.Filters
|
||||
[Test]
|
||||
public void CheckCorrectFile()
|
||||
{
|
||||
Md5Context ctx = new Md5Context();
|
||||
string result = ctx.File(location, out _);
|
||||
string result = Md5Context.File(location, out _);
|
||||
Assert.AreEqual(EXPECTED_FILE, result);
|
||||
}
|
||||
|
||||
@@ -86,8 +85,7 @@ namespace DiscImageChef.Tests.Filters
|
||||
str.Close();
|
||||
str.Dispose();
|
||||
filter.Close();
|
||||
Md5Context ctx = new Md5Context();
|
||||
string result = ctx.Data(data, out _);
|
||||
string result = Md5Context.Data(data, out _);
|
||||
Assert.AreEqual(EXPECTED_CONTENTS, result);
|
||||
}
|
||||
|
||||
@@ -102,8 +100,7 @@ namespace DiscImageChef.Tests.Filters
|
||||
str.Close();
|
||||
str.Dispose();
|
||||
filter.Close();
|
||||
Md5Context ctx = new Md5Context();
|
||||
string result = ctx.Data(data, out _);
|
||||
string result = Md5Context.Data(data, out _);
|
||||
Assert.AreEqual(EXPECTED_RESOURCE, result);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,8 +49,7 @@ namespace DiscImageChef.Tests.Filters
|
||||
[Test]
|
||||
public void CheckCorrectFile()
|
||||
{
|
||||
Md5Context ctx = new Md5Context();
|
||||
string result = ctx.File(location, out _);
|
||||
string result = Md5Context.File(location, out _);
|
||||
Assert.AreEqual(EXPECTED_FILE, result);
|
||||
}
|
||||
|
||||
@@ -86,8 +85,7 @@ namespace DiscImageChef.Tests.Filters
|
||||
str.Close();
|
||||
str.Dispose();
|
||||
filter.Close();
|
||||
Md5Context ctx = new Md5Context();
|
||||
string result = ctx.Data(data, out _);
|
||||
string result = Md5Context.Data(data, out _);
|
||||
Assert.AreEqual(EXPECTED_CONTENTS, result);
|
||||
}
|
||||
|
||||
@@ -102,8 +100,7 @@ namespace DiscImageChef.Tests.Filters
|
||||
str.Close();
|
||||
str.Dispose();
|
||||
filter.Close();
|
||||
Md5Context ctx = new Md5Context();
|
||||
string result = ctx.Data(data, out _);
|
||||
string result = Md5Context.Data(data, out _);
|
||||
Assert.AreEqual(EXPECTED_RESOURCE, result);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,8 +49,7 @@ namespace DiscImageChef.Tests.Filters
|
||||
[Test]
|
||||
public void CheckCorrectFile()
|
||||
{
|
||||
Md5Context ctx = new Md5Context();
|
||||
string result = ctx.File(location, out _);
|
||||
string result = Md5Context.File(location, out _);
|
||||
Assert.AreEqual(EXPECTED_FILE, result);
|
||||
}
|
||||
|
||||
@@ -86,8 +85,7 @@ namespace DiscImageChef.Tests.Filters
|
||||
str.Close();
|
||||
str.Dispose();
|
||||
filter.Close();
|
||||
Md5Context ctx = new Md5Context();
|
||||
string result = ctx.Data(data, out _);
|
||||
string result = Md5Context.Data(data, out _);
|
||||
Assert.AreEqual(EXPECTED_CONTENTS, result);
|
||||
}
|
||||
|
||||
@@ -102,8 +100,7 @@ namespace DiscImageChef.Tests.Filters
|
||||
str.Close();
|
||||
str.Dispose();
|
||||
filter.Close();
|
||||
Md5Context ctx = new Md5Context();
|
||||
string result = ctx.Data(data, out _);
|
||||
string result = Md5Context.Data(data, out _);
|
||||
Assert.AreEqual(EXPECTED_RESOURCE, result);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,9 +49,8 @@ namespace DiscImageChef.Tests.Filters
|
||||
[Test]
|
||||
public void CheckCorrectFile()
|
||||
{
|
||||
Md5Context ctx = new Md5Context();
|
||||
string result = ctx.File(Path.Combine(Consts.TestFilesRoot, "filters", "pcexchange", "FINDER.DAT"),
|
||||
out _);
|
||||
string result = Md5Context.File(Path.Combine(Consts.TestFilesRoot, "filters", "pcexchange", "FINDER.DAT"),
|
||||
out _);
|
||||
Assert.AreEqual(EXPECTED_FILE, result);
|
||||
}
|
||||
|
||||
@@ -87,8 +86,7 @@ namespace DiscImageChef.Tests.Filters
|
||||
str.Close();
|
||||
str.Dispose();
|
||||
filter.Close();
|
||||
Md5Context ctx = new Md5Context();
|
||||
string result = ctx.Data(data, out _);
|
||||
string result = Md5Context.Data(data, out _);
|
||||
Assert.AreEqual(EXPECTED_CONTENTS, result);
|
||||
}
|
||||
|
||||
@@ -103,8 +101,7 @@ namespace DiscImageChef.Tests.Filters
|
||||
str.Close();
|
||||
str.Dispose();
|
||||
filter.Close();
|
||||
Md5Context ctx = new Md5Context();
|
||||
string result = ctx.Data(data, out _);
|
||||
string result = Md5Context.Data(data, out _);
|
||||
Assert.AreEqual(EXPECTED_RESOURCE, result);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,8 +50,7 @@ namespace DiscImageChef.Tests.Filters
|
||||
[Test]
|
||||
public void CheckCorrectFile()
|
||||
{
|
||||
Md5Context ctx = new Md5Context();
|
||||
byte[] result = ctx.File(location);
|
||||
byte[] result = Md5Context.File(location);
|
||||
Assert.AreEqual(ExpectedFile, result);
|
||||
}
|
||||
|
||||
@@ -87,8 +86,7 @@ namespace DiscImageChef.Tests.Filters
|
||||
str.Close();
|
||||
str.Dispose();
|
||||
filter.Close();
|
||||
Md5Context ctx = new Md5Context();
|
||||
ctx.Data(data, out byte[] result);
|
||||
Md5Context.Data(data, out byte[] result);
|
||||
Assert.AreEqual(ExpectedContents, result);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,7 +84,6 @@ namespace DiscImageChef.Commands
|
||||
|
||||
foreach(Track currentTrack in inputTracks)
|
||||
{
|
||||
Sha1Context sha1CtxTrack = new Sha1Context();
|
||||
entTable = new ulong[256];
|
||||
ulong trackSize = 0;
|
||||
List<string> uniqueSectorsPerTrack = new List<string>();
|
||||
@@ -99,7 +98,7 @@ namespace DiscImageChef.Commands
|
||||
|
||||
if(options.DuplicatedSectors)
|
||||
{
|
||||
string sectorHash = sha1CtxTrack.Data(sector, out _);
|
||||
string sectorHash = Sha1Context.Data(sector, out _);
|
||||
if(!uniqueSectorsPerTrack.Contains(sectorHash)) uniqueSectorsPerTrack.Add(sectorHash);
|
||||
}
|
||||
|
||||
@@ -129,7 +128,6 @@ namespace DiscImageChef.Commands
|
||||
|
||||
if(!options.WholeDisc) return;
|
||||
|
||||
Sha1Context sha1Ctx = new Sha1Context();
|
||||
entTable = new ulong[256];
|
||||
ulong diskSize = 0;
|
||||
List<string> uniqueSectors = new List<string>();
|
||||
@@ -144,7 +142,7 @@ namespace DiscImageChef.Commands
|
||||
|
||||
if(options.DuplicatedSectors)
|
||||
{
|
||||
string sectorHash = sha1Ctx.Data(sector, out _);
|
||||
string sectorHash = Sha1Context.Data(sector, out _);
|
||||
if(!uniqueSectors.Contains(sectorHash)) uniqueSectors.Add(sectorHash);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user