/// <summary> /// Create the specified hashing algorithm. /// </summary> /// <returns>The created algorithm.</returns> /// <param name="algorithm">The name of the hash algorithm to create.</param> /// <param name="allowfallback">If set to <c>true</c>, the `<seealso cref="System.Security.Cryptography.HashAlgorithm.Create()"/> method is called if not implementation could be loaded</param> /// <param name="implementation">The hash implementation toy use</param> public static HashAlgorithm Create(string algorithm, bool allowfallback = true, HashImplementation implementation = HashImplementation.Any) { HashAlgorithm result = null; // If we are not asked for a particular version, pick the best we found if (implementation == HashImplementation.Any) { implementation = PreferedImplementation; } switch (implementation) { case HashImplementation.OpenSSL10: result = OpenSSL10HashAlgorithm.Create(algorithm); break; case HashImplementation.OpenSSL11: result = OpenSSL11HashAlgorithm.Create(algorithm); break; case HashImplementation.CNG: result = CNGHashAlgorithm.Create(algorithm, false); break; case HashImplementation.AppleCommonCrypto: result = AppleCommonCryptoHashAlgorithm.Create(algorithm); break; case HashImplementation.Managed: result = HashAlgorithm.Create(algorithm); break; } if (allowfallback) { result = result ?? HashAlgorithm.Create(algorithm); } return(result); }
/// <summary> /// Initializes a new instance of the <see cref="T:FasterHashing.AppleCommonCryptoSHA512"/> class. /// </summary> public AppleCommonCryptoSHA512() { m_size = AppleCommonCryptoHashAlgorithm.GetDigestSize(AppleCCDigest.SHA512); }
/// <summary> /// Initializes a new instance of the <see cref="T:FasterHashing.AppleCommonCryptoMD5"/> class. /// </summary> public AppleCommonCryptoMD5() { m_size = AppleCommonCryptoHashAlgorithm.GetDigestSize(AppleCCDigest.MD5); }