/// <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]); }
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]); }
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"); } }
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"); } }
public static string GetOIDForProvider(HashProvider Provider) { return(CryptoConfig.MapNameToOID(Provider.ToString())); }
public static Oid GetOID(this HashProvider ForProvider) { return(Oid.FromFriendlyName(ForProvider.ToString(), OidGroup.HashAlgorithm)); }