コード例 #1
0
        void IDisposable.Dispose()
        {
#if RT
            this.hash = null;
#else
            if (!this.version1MD5)
            {
                if (this.nativeMD5Hash != null)
                {
                    this.nativeMD5Hash.Dispose();
                    this.nativeMD5Hash = null;
                }
            }
            else
            {
                this.hash = null;
            }
#endif
        }
コード例 #2
0
        /// <summary>
        /// Routes data written to the object into the hash algorithm for computing the hash.
        /// </summary>
        /// <param name="array">The input to compute the hash code for.</param>
        /// <param name="offset">The offset into the byte array from which to begin using data.</param>
        /// <param name="dataLen">The number of bytes in the byte array to use as data.</param>
        protected override void HashCore(byte[] array, int offset, int dataLen)
        {
            GCHandle handle = GCHandle.Alloc(array, GCHandleType.Pinned);

            try
            {
                IntPtr buffPtr = handle.AddrOfPinnedObject();
                if (offset != 0)
                {
                    buffPtr = IntPtr.Add(buffPtr, offset);
                }

                NativeMD5.ValidateReturnCode(NativeMethods.CryptHashData(this.hashHandle, buffPtr, dataLen, 0));
            }
            finally
            {
                handle.Free();
            }
        }
コード例 #3
0
 /// <summary>
 /// Initializes a new instance of NativeMD5.
 /// </summary>
 public NativeMD5()
     : base()
 {
     NativeMD5.ValidateReturnCode(NativeMethods.CryptAcquireContextW(out this.hashProv, null, null, ProvRsaFull, CryptVerifyContext));
     this.Initialize();
 }