Example #1
0
 /// <summary>
 /// Gets the checksum of the given buffer.
 /// </summary>
 /// <param name="bytes">The bytes.</param>
 /// <param name="offset">The offset.</param>
 /// <param name="count">The count.</param>
 /// <param name="checksum">The checksum.</param>
 /// <returns></returns>
 public static UInt32 GetChecksum32(this byte[] bytes, int offset, int count, UInt32 checksum = 0)
 {
     count += offset;
     for (int index = offset; index < count; index++)
     {
         checksum = checksum.RotateRight() + bytes[index];
     }
     return(checksum);
 }
Example #2
0
 private void Write(Stream stream, byte b, ref UInt32 c)
 {
     stream.WriteByte(b);
     c = c.RotateRight() + b;
 }
Example #3
0
        public void RotationRight(UInt32 original, Int32 amount, UInt32 expected)
        {
            UInt32 rotated = original.RotateRight(amount);

            Assert.Equal(expected, rotated);
        }