MalwareSourceCode/MSIL/Trojan-Ransom/Win32/G/Trojan-Ransom.Win32.Gimemo.ayt-624a52079bf1703bcd3bcc9d2d3716b6126fd05655e25289d19142f9aae02eb5/CRC.cs
2022-08-18 06:28:56 -05:00

54 lines
1.7 KiB
C#

// Decompiled with JetBrains decompiler
// Type: SevenZip.CRC
// Assembly: P4CTEMP, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
// MVID: 7BE4E538-8555-4C2E-974B-99E556F5462C
// Assembly location: C:\Users\Administrateur\Downloads\Virusshare-00000-msil\Trojan-Ransom.Win32.Gimemo.ayt-624a52079bf1703bcd3bcc9d2d3716b6126fd05655e25289d19142f9aae02eb5.exe
using System;
namespace SevenZip
{
internal class CRC
{
public static readonly uint[] Table = new uint[256];
private uint _value = uint.MaxValue;
static CRC()
{
for (uint index1 = 0; index1 < 256U; ++index1)
{
uint num = index1;
for (int index2 = 0; index2 < 8; ++index2)
{
if (((int) num & 1) != 0)
num = num >> 1 ^ 3988292384U;
else
num >>= 1;
}
CRC.Table[(IntPtr) index1] = num;
}
}
public void Init() => this._value = uint.MaxValue;
public void UpdateByte(byte b) => this._value = CRC.Table[(int) (byte) this._value ^ (int) b] ^ this._value >> 8;
public void Update(byte[] data, uint offset, uint size)
{
for (uint index = 0; index < size; ++index)
this._value = CRC.Table[(int) (byte) this._value ^ (int) data[(IntPtr) (offset + index)]] ^ this._value >> 8;
}
public uint GetDigest() => this._value ^ uint.MaxValue;
private static uint CalculateDigest(byte[] data, uint offset, uint size)
{
CRC crc = new CRC();
crc.Update(data, offset, size);
return crc.GetDigest();
}
private static bool VerifyDigest(uint digest, byte[] data, uint offset, uint size) => (int) CRC.CalculateDigest(data, offset, size) == (int) digest;
}
}