Exemplo n.º 1
0
        public uint Finish()
        {
            if (!mFinished)
            {
                mFinished = true;
                mCRC      = CRC.Finish(mCRC);
            }

            return(mCRC);
        }
Exemplo n.º 2
0
        protected override void Dispose(bool disposing)
        {
            try
            {
                if (disposing && !mClosed)
                {
                    mClosed     = true;
                    mCurrentCRC = CRC.Finish(mCurrentCRC);
#if DEBUG
                    if (mCurrentCRC == mExpectedCRC)
                    {
                        System.Diagnostics.Debug.WriteLine("CRC ok: " + mExpectedCRC.ToString("x8"));
                    }
                    else
                    {
                        System.Diagnostics.Debugger.Break();
                        System.Diagnostics.Debug.WriteLine("bad CRC");
                    }

                    double lengthInv = 1.0 / mLength;
                    double entropy   = 0;
                    for (int i = 0; i < 256; i++)
                    {
                        if (mBytes[i] != 0)
                        {
                            double p = lengthInv * mBytes[i];
                            entropy -= p * Math.Log(p, 256);
                        }
                    }
                    System.Diagnostics.Debug.WriteLine("entropy: " + (int)(entropy * 100) + "%");
#endif
                }
            }
            finally
            {
                base.Dispose(disposing);
            }
        }