using GostCryptography.Config;
using System;

namespace GostXades.Helpers
{
    public static class GostHashAlgorithmHelper
    {
        /// <summary>
        /// Рассчитать хэш
        /// </summary>
        /// <param name="cryptoProviderType">Тип криптопровайдера</param>
        /// <param name="bytes"></param>
        /// <returns></returns>
        public static string ComputeHash(CryptoProviderTypeEnum cryptoProviderType, byte[] bytes)
        {
            byte[] hashValue;
            GostCryptoConfig.ProviderType = (GostCryptography.Base.ProviderType)cryptoProviderType;
            var hashAlgorithm = new GostCryptography.Gost_R3411.Gost_R3411_2012_512_HashAlgorithm();
            hashValue = hashAlgorithm.ComputeHash(bytes);
            return BitConverter.ToString(hashValue).Replace("-", "");
        }
    }
}
