protected override void ProcessStream(BinaryReader reader, ComponentDataPool componentDataPool, out uint hashCode, out int startIndex, out int length) { MemoryStream memoryStream = (MemoryStream)componentDataPool.ConstStringDataReader.BaseStream; memoryStream.Seek(0L, SeekOrigin.Begin); length = this.Read7BitEncodedInt(reader, memoryStream); if (length < 0) { throw new FormatException("size tag should >= 0"); } startIndex = (int)memoryStream.Position; memoryStream.SetLength((long)(startIndex + length)); byte[] copyBuffer = componentDataPool.CopyBuffer; int num; for (int i = length; i > 0; i -= num) { num = ((i > copyBuffer.Length) ? copyBuffer.Length : i); if (reader.Read(copyBuffer, 0, num) != num) { throw new FormatException("there are less bytes than what tag says"); } memoryStream.Write(copyBuffer, 0, num); } hashCode = ComputeCRC.Compute(0U, memoryStream.GetBuffer(), startIndex, length); }
private static uint ComputeChecksum(byte[][] memberIds) { uint num = 0U; foreach (byte[] bytes in memberIds) { num = ComputeCRC.Compute(num, bytes); } return(num); }
internal override void SetEntryId(DefaultFolderContext context, byte[] entryId) { byte[][] array = this.GetLocationPropertyBag(context).TryGetProperty(this.Property) as byte[][]; byte[][] array2 = Ex12MultivalueEntryIdStrategy.CreateMultiValuedPropertyValue(array, entryId, this.index, 6); if (array == null || array.Length <= 5) { uint value = ComputeCRC.Compute(0U, entryId); array2[5] = BitConverter.GetBytes(value); } base.SetEntryValueInternal(context, array2); }
public static uint Compute(Stream stream) { long position = stream.Position; stream.Seek(0L, SeekOrigin.Begin); uint num = 0U; int num2 = 131072; byte[] array = new byte[num2]; for (;;) { int num3 = stream.Read(array, 0, num2); if (num3 == 0) { break; } num = ComputeCRC.Compute(num, array, 0, num3); } stream.Seek(position, SeekOrigin.Begin); return(num); }
internal static uint Compute(uint orgCRC, byte[] bytes) { return(ComputeCRC.Compute(orgCRC, bytes, 0, bytes.Length)); }
protected override void ProcessData(string data, out uint hashCode, out byte[] bytes) { bytes = Encoding.UTF8.GetBytes(data); hashCode = ComputeCRC.Compute(0U, bytes); }