public BCryptHashAlgorithm(CngAlgorithm algorithm, string implementation) { if (!BCryptNative.BCryptSupported) { throw new PlatformNotSupportedException(System.SR.GetString("Cryptography_PlatformNotSupported")); } this.m_algorithmHandle = BCryptNative.OpenAlgorithm(algorithm.Algorithm, implementation); this.Initialize(); }
public SafeBCryptAlgorithmHandle GetCachedAlgorithmHandle(string algorithm, string implementation) { string handleKey = algorithm + implementation; SafeBCryptAlgorithmHandle algorithmHandle = null; if (m_algorithmHandles.ContainsKey(handleKey)) { algorithmHandle = m_algorithmHandles[handleKey].Target as SafeBCryptAlgorithmHandle; if (algorithmHandle != null) { return(algorithmHandle); } } algorithmHandle = BCryptNative.OpenAlgorithm(algorithm, implementation); m_algorithmHandles[handleKey] = new WeakReference(algorithmHandle); return(algorithmHandle); }