コード例 #1
0
        /// <summary>
        /// The create hash.
        /// </summary>
        /// <param name="keyContext">
        /// The key context.
        /// </param>
        /// <param name="algid">
        /// The algid.
        /// </param>
        /// <param name="flags">
        /// The flags.
        /// </param>
        /// <returns>
        /// The <see cref="HashContext"/>.
        /// </returns>
        /// <exception cref="Win32Exception">
        /// </exception>
        private HashContext CreateHash(KeyContext keyContext, int algid, int flags)
        {
            var hashHandler = IntPtr.Zero;
            var keyHandler  = IntPtr.Zero;

            if (keyContext != null)
            {
                keyHandler = keyContext.Handler;
            }

            if (!CryptoApi.CryptCreateHash(cspHandler, algid, keyHandler, flags, ref hashHandler))
            {
                throw new Win32Exception();
            }

            var hashContext = new HashContext(hashHandler);

            return(hashContext);
        }
コード例 #2
0
        internal HashContext CreateHash(KeyContext keyContext, int flags)
        {
            int algid = ProviderParams.GetHashAlgId();

            IntPtr hashHandler = IntPtr.Zero;
            IntPtr keyHandler  = IntPtr.Zero;

            if (keyContext != null)
            {
                keyHandler = keyContext.Handler;
            }

            if (!CryptoApi.CryptCreateHash(cspHandler, algid, keyHandler, flags, ref hashHandler))
            {
                throw new Win32Exception();
            }

            var hashContext = new HashContext(hashHandler);

            return(hashContext);
        }