本文整理汇总了C#中Crc32.Add方法的典型用法代码示例。如果您正苦于以下问题:C# Crc32.Add方法的具体用法?C# Crc32.Add怎么用?C# Crc32.Add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Crc32
的用法示例。
在下文中一共展示了Crc32.Add方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AssertCrc32
private static void AssertCrc32(byte[] input, int expected)
{
Crc32 crc = new Crc32(input);
Assert.AreEqual(expected, crc.Value);
crc = new Crc32(0);
crc.Add(input);
Assert.AreEqual(expected, crc.Value);
crc = new Crc32();
crc.Add(input, 0, input.Length);
Assert.AreEqual(expected, crc.Value);
crc = new Crc32();
foreach (byte b in input)
crc.Add(b);
Assert.AreEqual(expected, crc.Value);
}
示例2: BlockStreamReader
public BlockStreamReader(FragmentedFile file, long ordinal, BlockFlags typeExpected, bool validated)
{
_file = file;
_blockPos = 0;
_validated = validated;
_block = new FileBlock(file._blockSize, file._useAlignedIo);
_file.ReadBlock(ordinal, _block, file._blockSize, typeExpected, _validated);
if (_validated)
{
_expectedSum = _block.CheckSum;
_checksum = new Crc32();
_checksum.Add(_block.BlockData, _block.DataOffset, _block.Length);
if (_block.NextBlockId == 0 && _checksum != _expectedSum)
throw new InvalidDataException();
}
}
示例3: TestAddByteRange
public void TestAddByteRange()
{
Crc32 all = new Crc32(new byte[] { 0x2, 0x3, 0x4, 0x5, 0x6 });
Crc32 crc = new Crc32();
Assert.AreEqual(0, crc.Value);
crc.Add(new byte[] { 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8 }, 1, 5);
Assert.AreEqual(all.Value, crc.Value);
}
示例4: TestHashValue
public void TestHashValue()
{
Crc32 crc = new Crc32();
Assert.AreEqual(0, crc.Value);
Assert.AreEqual(0, crc.GetHashCode());
crc.Add(0x1b);
Assert.AreNotEqual(0, crc.Value);
Assert.AreEqual(crc.Value, crc.GetHashCode());
}