We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent f2813c7 commit 0f6a5dbCopy full SHA for 0f6a5db
1 file changed
src/LibDeflate/Checksums/Crc32.cs
@@ -0,0 +1,23 @@
1
+using System;
2
+using System.Runtime.InteropServices;
3
+
4
+namespace LibDeflate.Checksums
5
+{
6
+ using static Imports.Checksums;
7
8
+ public struct Crc32
9
+ {
10
+ private uint _currentCrc;
11
12
+ public uint Hash => _currentCrc;
13
14
+ public void Append(ReadOnlySpan<byte> input)
15
+ => _currentCrc = AppendCore(_currentCrc, input);
16
17
+ public uint Compute(ReadOnlySpan<byte> input)
18
+ => _currentCrc = AppendCore(0, input);
19
20
+ private static uint AppendCore(uint crc, ReadOnlySpan<byte> input)
21
+ => libdeflate_crc32(crc, MemoryMarshal.GetReference(input), (nuint)input.Length);
22
+ }
23
+}
0 commit comments