Example #1
0
 public void Dispose()
 {
     if (handle != IntPtr.Zero)
     {
         // this frees the hashing structure, but allocates the digest
         IntPtr digest = MHashWrapper.mhash_end(handle);
         // so we still have a second free to make to complete dispose
         Marshal.FreeHGlobal(digest);
         handle = IntPtr.Zero;
         GC.SuppressFinalize(this);
     }
 }
Example #2
0
        public byte[] HashFinal()
        {
            byte[] result = new byte [blocksize];
            IntPtr digest = MHashWrapper.mhash_end(handle);

            try {
                Marshal.Copy(digest, result, 0, blocksize);
            }
            finally {
                Marshal.FreeHGlobal(digest);
                handle = IntPtr.Zero;
            }
            return(result);
        }