public void Clear_ShouldClearState() { var state = new SpongeState(BitString.Random(new Random(), 48), 24); Assert.IsTrue(state.BitString.Any(b => b)); state.Clear(); Assert.IsFalse(state.BitString.Any(b => b)); }
/// <summary> /// /// </summary> /// <param name="bytes"></param> /// <param name="length"></param> protected virtual void Absorb(byte[] bytes, int length) { State.Clear(); Bitstring message = new Bitstring(bytes, length); int rate = State.Rate; message.Append(Suffix()); message.Append(GetPadding(rate, message.Length)); int n = message.Length / rate; Bitstring zeroes = new Bitstring(Capacity); Bitstring chunk; for (int i = 0; i < n; i++) { chunk = message.Substring(rate * i, rate); chunk.Append(zeroes); State.Bitstring.Xor(chunk); Function(); } }