Beispiel #1
0
        /// <summary>
        /// Вернет список криптопровайдеров
        /// </summary>
        /// <returns></returns>
        public static Dictionary <string, int> GetProviders()
        {
            Dictionary <string, int> installedCSPs = new Dictionary <string, int>();
            uint          cbName;
            uint          dwType;
            uint          dwIndex;
            StringBuilder pszName;

            dwIndex = 0;
            dwType  = 1;
            cbName  = 0;
            while (CryptoApi.CryptEnumProviders(dwIndex, IntPtr.Zero, 0, ref dwType, null, ref cbName))
            {
                pszName = new StringBuilder((int)cbName);

                if (CryptoApi.CryptEnumProviders(dwIndex++, IntPtr.Zero, 0, ref dwType, pszName, ref cbName))
                {
                    installedCSPs.Add(pszName.ToString(), (int)dwType);
                }
            }
            return(installedCSPs);
        }