Пример #1
0
        /// <summary>
        /// The get sh a 256 hash hex string.
        /// </summary>
        /// <param name="value">
        /// The value.
        /// </param>
        /// <returns>
        /// The <see cref="string"/> .
        /// </returns>
        public static string GetSha256HashHexString(this string value)
        {
            if (string.IsNullOrEmpty(value))
            {
                return(string.Empty);
            }

            var cng    = new SHA256Cng();
            var buffer = cng.ComputeHash(value.GetBytes(Encoding.GetEncoding(0x4e3)));

            cng.Dispose();
            return(BitConverter.ToString(buffer).Replace("-", string.Empty));
        }
Пример #2
0
 /// <summary></summary>
 public void Dispose()
 {
     if (_AesServices != null)
     {
         _AesServices.Clear();
         _AesServices = null;
     }
     if (_MD5Services != null)
     {
         _MD5Services.Dispose();
         _MD5Services = null;
     }
     if (_SHA1Services != null)
     {
         _SHA1Services.Dispose();
         _SHA1Services = null;
     }
     if (_SHA256Services != null)
     {
         _SHA256Services.Dispose();
         _SHA256Services = null;
     }
     if (_SHA384Services != null)
     {
         _SHA384Services.Dispose();
         _SHA384Services = null;
     }
     if (_SHA512Services != null)
     {
         _SHA512Services.Dispose();
         _SHA512Services = null;
     }
     if (_Pkcs11Library != null)
     {
         _Pkcs11Library.Dispose();
         _Pkcs11Library = null;
     }
     if (_Randomness != null)
     {
         _Randomness.Dispose();
         _Randomness = null;
     }
     if (_RsaServices != null)
     {
         _RsaServices.Clear();
         _RsaServices = null;
     }
 }