mirror of
https://github.com/vxunderground/MalwareSourceCode.git
synced 2024-12-22 19:36:11 +00:00
55 lines
2.6 KiB
C#
55 lines
2.6 KiB
C#
|
// Decompiled with JetBrains decompiler
|
|||
|
// Type: Microsoft.InfoCards.HashUtility
|
|||
|
// Assembly: infocard, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
|
|||
|
// MVID: ADE0A079-11DB-4A46-8BDE-D2A592CA8DEA
|
|||
|
// Assembly location: C:\Users\Administrateur\Downloads\Virusshare-00000-msil\Virus.Win32.Expiro.w-67b630ead60119692b9abbdfd8717c96904ef041127c2cae033c86b718eaa61e.exe
|
|||
|
|
|||
|
using Microsoft.InfoCards.Diagnostics;
|
|||
|
using System;
|
|||
|
using System.Security.Cryptography;
|
|||
|
|
|||
|
namespace Microsoft.InfoCards
|
|||
|
{
|
|||
|
internal static class HashUtility
|
|||
|
{
|
|||
|
public const string HashAlgorithmName = "SHA256";
|
|||
|
private static object s_lock = new object();
|
|||
|
private static SHA256Managed s_hasher = new SHA256Managed();
|
|||
|
|
|||
|
public static int HashBitLength => HashUtility.s_hasher.HashSize;
|
|||
|
|
|||
|
public static int HashBufferLength => HashUtility.HashBitLength / 8;
|
|||
|
|
|||
|
public static void SetHashValue(byte[] data, int dataIndex, byte[] dataToHash)
|
|||
|
{
|
|||
|
if (dataToHash == null)
|
|||
|
throw InfoCardTrace.ThrowHelperArgumentNull(nameof (dataToHash));
|
|||
|
HashUtility.SetHashValue(data, dataIndex, dataToHash, 0, dataToHash.Length);
|
|||
|
}
|
|||
|
|
|||
|
public static void SetHashValue(
|
|||
|
byte[] data,
|
|||
|
int dataIndex,
|
|||
|
byte[] dataToHash,
|
|||
|
int dataToHashIndex,
|
|||
|
int dataToHashSize)
|
|||
|
{
|
|||
|
if (data == null)
|
|||
|
throw InfoCardTrace.ThrowHelperArgumentNull(nameof (data));
|
|||
|
if (dataIndex < 0 || dataIndex >= data.Length)
|
|||
|
throw InfoCardTrace.ThrowHelperError((Exception) new ArgumentOutOfRangeException(nameof (dataIndex), (object) dataIndex, SR.GetString("StoreHashUtilityDataOutOfRange")));
|
|||
|
if (dataToHash == null)
|
|||
|
throw InfoCardTrace.ThrowHelperArgumentNull(nameof (dataToHash));
|
|||
|
if (dataToHashIndex < 0 || dataToHashIndex > dataToHash.Length)
|
|||
|
throw InfoCardTrace.ThrowHelperError((Exception) new ArgumentOutOfRangeException(nameof (dataToHashIndex), (object) dataToHashIndex, SR.GetString("StoreHashUtilityDataToHashOutOfRange")));
|
|||
|
if (dataToHashSize < 0 || dataToHashSize > dataToHash.Length - dataToHashIndex)
|
|||
|
throw InfoCardTrace.ThrowHelperError((Exception) new ArgumentOutOfRangeException(nameof (dataToHashIndex), (object) dataToHashIndex, SR.GetString("StoreHashUtilityDataToHashOutOfRange")));
|
|||
|
byte[] sourceArray = (byte[]) null;
|
|||
|
lock (HashUtility.s_lock)
|
|||
|
sourceArray = HashUtility.s_hasher.ComputeHash(dataToHash, dataToHashIndex, dataToHashSize);
|
|||
|
Array.Copy((Array) sourceArray, 0, (Array) data, dataIndex, sourceArray.Length);
|
|||
|
Array.Clear((Array) sourceArray, 0, sourceArray.Length);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|