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(); }
public void ComputeChecksum_ExceptionTest() { Sha256 sha = new Sha256(); Assert.Throws <ArgumentNullException>(() => sha.ComputeChecksum(null)); sha.Dispose(); Assert.Throws <ObjectDisposedException>(() => sha.ComputeChecksum(new byte[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)); }
/// <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; } }
/// <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); }
public void Dispose() { _socket.Dispose(); _hash.Dispose(); }
public void Dispose() { _pipe.Dispose(); _hash.Dispose(); }