MalwareSourceCode/MSIL/Virus/Win32/E/Virus.Win32.Expiro.w-69bb73081eac86b8cf86f45e33515d0095855636967076e2b593d7a30cd80a07/Microsoft/InfoCards/HashUtility.cs
2022-08-18 06:28:56 -05:00

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: 516D8B44-4448-4D2C-8B8E-FFBB3FFE472B
// Assembly location: C:\Users\Administrateur\Downloads\Virusshare-00000-msil\Virus.Win32.Expiro.w-69bb73081eac86b8cf86f45e33515d0095855636967076e2b593d7a30cd80a07.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);
}
}
}