mirror of
https://github.com/SteamRE/DepotDownloader.git
synced 2026-02-04 05:31:18 +01:00
Remove inlined adler hash
This commit is contained in:
@@ -1059,18 +1059,7 @@ namespace DepotDownloader
|
||||
{
|
||||
fsOld.Seek((long)match.OldChunk.Offset, SeekOrigin.Begin);
|
||||
|
||||
uint a = 0, b = 0;
|
||||
|
||||
for (var i = 0; i < match.OldChunk.UncompressedLength; i++)
|
||||
{
|
||||
var c = (uint)fsOld.ReadByte();
|
||||
|
||||
// adler hash
|
||||
a = (a + c) % 65521;
|
||||
b = (b + a) % 65521;
|
||||
}
|
||||
|
||||
var adler = BitConverter.GetBytes(a | (b << 16));
|
||||
var adler = Util.AdlerHash(fsOld, (int)match.OldChunk.UncompressedLength);
|
||||
if (!adler.SequenceEqual(match.OldChunk.Checksum))
|
||||
{
|
||||
neededChunks.Add(match.NewChunk);
|
||||
|
||||
@@ -83,18 +83,7 @@ namespace DepotDownloader
|
||||
{
|
||||
fs.Seek((long)data.Offset, SeekOrigin.Begin);
|
||||
|
||||
uint a = 0, b = 0;
|
||||
|
||||
for (var i = 0; i < data.UncompressedLength; i++)
|
||||
{
|
||||
var c = (uint)fs.ReadByte();
|
||||
|
||||
// adler hash
|
||||
a = (a + c) % 65521;
|
||||
b = (b + a) % 65521;
|
||||
}
|
||||
|
||||
var adler = BitConverter.GetBytes(a | (b << 16));
|
||||
var adler = AdlerHash(fs, (int)data.UncompressedLength);
|
||||
if (!adler.SequenceEqual(data.Checksum))
|
||||
{
|
||||
neededChunks.Add(data);
|
||||
@@ -104,6 +93,20 @@ namespace DepotDownloader
|
||||
return neededChunks;
|
||||
}
|
||||
|
||||
public static byte[] AdlerHash(Stream stream, int length)
|
||||
{
|
||||
uint a = 0, b = 0;
|
||||
for (var i = 0; i < length; i++)
|
||||
{
|
||||
var c = (uint)stream.ReadByte();
|
||||
|
||||
a = (a + c) % 65521;
|
||||
b = (b + a) % 65521;
|
||||
}
|
||||
|
||||
return BitConverter.GetBytes(a | (b << 16));
|
||||
}
|
||||
|
||||
public static byte[] DecodeHexString(string hex)
|
||||
{
|
||||
if (hex == null)
|
||||
|
||||
Reference in New Issue
Block a user