コード例 #1
0
        public void ComputeHash_NistMonteCarloTest()
        {
            byte[]  seed  = Helper.HexToBytes("6d1e72ad03ddeb5de891e572e2396f8da015d899ef0e79503152d6010a3fe691");
            JObject jObjs = Helper.ReadResources <JObject>("Sha256NistTestData");
            int     size  = 32;

            byte[] toHash = new byte[3 * size];

            byte[] M0 = seed;
            byte[] M1 = seed;
            byte[] M2 = seed;

            Sha256 sha = new Sha256(false);

            foreach (var item in jObjs["MonteCarlo"])
            {
                byte[] expected = Helper.HexToBytes(item.ToString());
                for (int i = 0; i < 1000; i++)
                {
                    Buffer.BlockCopy(M0, 0, toHash, 0, size);
                    Buffer.BlockCopy(M1, 0, toHash, size, size);
                    Buffer.BlockCopy(M2, 0, toHash, size * 2, size);

                    M0 = M1;
                    M1 = M2;
                    M2 = sha.ComputeHash(toHash);
                }
                M0 = M2;
                M1 = M2;

                Assert.Equal(expected, M2);
            }

            sha.Dispose();
        }
コード例 #2
0
        public void ComputeChecksum_ExceptionTest()
        {
            Sha256 sha = new Sha256();

            Assert.Throws <ArgumentNullException>(() => sha.ComputeChecksum(null));
            sha.Dispose();
            Assert.Throws <ObjectDisposedException>(() => sha.ComputeChecksum(new byte[0]));
        }
コード例 #3
0
        public void ComputeHash_ExceptionsTest()
        {
            byte[] goodBa = { 1, 2, 3 };
            Sha256 sha    = new Sha256();

            Assert.Throws <ArgumentNullException>(() => sha.ComputeHash(null));

            sha.Dispose();
            Assert.Throws <ObjectDisposedException>(() => sha.ComputeHash(goodBa));
        }
コード例 #4
0
        /// <summary>
        /// Releases the resources used by the <see cref="Miner"/> class.
        /// </summary>
        /// <param name="disposing">
        /// True to release both managed and unmanaged resources; false to release only unmanaged resources.
        /// </param>
        protected virtual void Dispose(bool disposing)
        {
            if (!isDisposed)
            {
                if (disposing)
                {
                    if (!(sha is null))
                    {
                        sha.Dispose();
                    }
                    sha = null;
                }

                isDisposed = true;
            }
        }
コード例 #5
0
        /// <summary>
        /// Releases the resources used by the <see cref="MiniPrivateKey"/> class.
        /// </summary>
        /// <param name="disposing">
        /// True to release both managed and unmanaged resources; false to release only unmanaged resources.
        /// </param>
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (hash != null)
                {
                    hash.Dispose();
                }
                hash = null;

                if (smallBytes != null)
                {
                    Array.Clear(smallBytes, 0, smallBytes.Length);
                }
                smallBytes = null;
            }

            base.Dispose(disposing);
        }
コード例 #6
0
ファイル: StorageClient.cs プロジェクト: safern/corefxlab
 public void Dispose()
 {
     _socket.Dispose();
     _hash.Dispose();
 }
コード例 #7
0
 public void Dispose()
 {
     _pipe.Dispose();
     _hash.Dispose();
 }