コード例 #1
0
        /// <summary>
        /// Gets a HashAlgorithm from a HashProvider using a no-search static array
        /// </summary>
        private static HashAlgorithm GetHashAlgorithm(HashProvider Provider)
        {
            if (hashAlgorithms[(int)Provider] == null)
            {
                var h = HashAlgorithm.Create(Provider.ToString());
                hashAlgorithms[(int)Provider] = h;
            }

            return(hashAlgorithms[(int)Provider]);
        }
コード例 #2
0
        public static HashAlgorithm GetHashAlgorithm(this HashProvider Provider)
        {
            if (hashAlgorithms[(int)Provider] == null)
            {
                //var h = HashAlgorithm.Create(Provider.ToString());
                var h = (HashAlgorithm)CryptoConfig.CreateFromName(Provider.ToString());
                hashAlgorithms[(int)Provider] = h;
            }

            return(hashAlgorithms[(int)Provider]);
        }
コード例 #3
0
        public static HashAlgorithmName GetHashAlgorithmName(this HashProvider Provider)
        {
            switch (Provider)
            {
            case HashProvider.SHA256:
                return(HashAlgorithmName.SHA256);

            case HashProvider.SHA384:
                return(HashAlgorithmName.SHA384);

            case HashProvider.SHA512:
                return(HashAlgorithmName.SHA512);

            default:
                throw new NotImplementedException("Hash provider '" + Provider.ToString() + "' not implemented in GetHashAlgorithmName");
            }
        }
コード例 #4
0
        public static int GetProviderByteLength(this HashProvider ForProvider)
        {
            switch (ForProvider)
            {
            case HashProvider.SHA256:
                return(32);

            case HashProvider.SHA384:
                return(48);

            case HashProvider.SHA512:
                return(64);

            default:
                throw new NotImplementedException("Hash provider '" + ForProvider.ToString() + "' not implemented in GetHashByteLength");
            }
        }
コード例 #5
0
 public static string GetOIDForProvider(HashProvider Provider)
 {
     return(CryptoConfig.MapNameToOID(Provider.ToString()));
 }
コード例 #6
0
 public static Oid GetOID(this HashProvider ForProvider)
 {
     return(Oid.FromFriendlyName(ForProvider.ToString(), OidGroup.HashAlgorithm));
 }