mirror of
https://github.com/aaru-dps/Aaru.Server.git
synced 2025-12-16 19:24:27 +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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user