Changing CRC32 implementation

pull/50/head
Allex Rodrigues 3 years ago
parent b5fb3a1af0
commit e3abf499ba

@ -1,48 +0,0 @@
using System;
namespace UWPHook
{
public class Crc32
{
uint[] table;
public uint ComputeChecksum(byte[] bytes)
{
uint crc = 0xffffffff;
for (int i = 0; i < bytes.Length; ++i)
{
byte index = (byte)(((crc) & 0xff) ^ bytes[i]);
crc = (uint)((crc >> 8) ^ table[index]);
}
return ~crc;
}
public byte[] ComputeChecksumBytes(byte[] bytes)
{
return BitConverter.GetBytes(ComputeChecksum(bytes));
}
public Crc32()
{
uint poly = 0xedb88320;
table = new uint[256];
uint temp = 0;
for (uint i = 0; i < table.Length; ++i)
{
temp = i;
for (int j = 8; j > 0; --j)
{
if ((temp & 1) == 1)
{
temp = (uint)((temp >> 1) ^ poly);
}
else
{
temp >>= 1;
}
}
table[i] = temp;
}
}
}
}

@ -1,4 +1,5 @@
using SharpSteam;
using Force.Crc32;
using SharpSteam;
using System;
using System.Collections.Generic;
using System.ComponentModel;
@ -112,7 +113,7 @@ namespace UWPHook
private UInt64 GenerateSteamGridAppId(string appName, string appTarget)
{
byte[] nameTargetBytes = Encoding.UTF8.GetBytes(appTarget + appName + "");
UInt64 crc = new Crc32().ComputeChecksum(nameTargetBytes);
UInt64 crc = Crc32Algorithm.Compute(nameTargetBytes);
UInt64 gameId = crc | 0x80000000;
return gameId;

@ -59,6 +59,9 @@
<StartupObject>UWPHook.App</StartupObject>
</PropertyGroup>
<ItemGroup>
<Reference Include="Crc32.NET, Version=1.0.0.0, Culture=neutral, PublicKeyToken=dc0b95cf99bf4e99, processorArchitecture=MSIL">
<HintPath>..\packages\Crc32.NET.1.2.0\lib\net20\Crc32.NET.dll</HintPath>
</Reference>
<Reference Include="MaterialDesignColors, Version=1.2.6.1513, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\MaterialDesignColors.1.2.6\lib\net45\MaterialDesignColors.dll</HintPath>
</Reference>

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Crc32.NET" version="1.2.0" targetFramework="net461" />
<package id="MaterialDesignColors" version="1.2.6" targetFramework="net461" />
<package id="MaterialDesignThemes" version="3.1.3" targetFramework="net461" />
<package id="Microsoft.AspNet.WebApi.Client" version="5.2.7" targetFramework="net461" />

Loading…
Cancel
Save