private void CopyIn(Sha256Digest t) { base.CopyIn(t); H1 = t.H1; H2 = t.H2; H3 = t.H3; H4 = t.H4; H5 = t.H5; H6 = t.H6; H7 = t.H7; H8 = t.H8; Array.Copy(t.X, 0, X, 0, t.X.Length); xOff = t.xOff; }
public static uint256 Hash256(byte[] data, int offset, int count) { #if USEBC || WINDOWS_UWP Sha256Digest sha256 = new Sha256Digest(); sha256.BlockUpdate(data, offset, count); byte[] rv = new byte[32]; sha256.DoFinal(rv, 0); sha256.BlockUpdate(rv, 0, rv.Length); sha256.DoFinal(rv, 0); return new uint256(rv); #else using(var sha = new SHA256Managed()) { var h = sha.ComputeHash(data, offset, count); return new uint256(sha.ComputeHash(h, 0, h.Length)); } #endif }
public static byte[] SHA256(byte[] data, int offset, int count) { #if USEBC || WINDOWS_UWP Sha256Digest sha256 = new Sha256Digest(); sha256.BlockUpdate(data, offset, count); byte[] rv = new byte[32]; sha256.DoFinal(rv, 0); return rv; #else using(var sha = new SHA256Managed()) { return sha.ComputeHash(data, offset, count); } #endif }
/** * Copy constructor. This will copy the state of the provided * message digest. */ public Sha256Digest(Sha256Digest t) : base(t) { CopyIn(t); }
public override void Reset(IMemoable other) { Sha256Digest d = (Sha256Digest)other; CopyIn(d); }