File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ using System ;
2+ using System . Runtime . InteropServices ;
3+
4+ namespace LibDeflate . Checksums
5+ {
6+ using static Imports . Checksums ;
7+
8+ public struct Adler32
9+ {
10+ private bool _initialized ;
11+ //because we have to supply 1 as the initial value
12+ //we must always retrieve this through Hash
13+ private uint _currentAdler ;
14+ public uint Hash
15+ {
16+ get
17+ {
18+ if ( ! _initialized )
19+ {
20+ _currentAdler = 1 ;
21+ _initialized = true ;
22+ }
23+ return _currentAdler ;
24+ }
25+ }
26+
27+ public void Append ( ReadOnlySpan < byte > input )
28+ => _currentAdler = AppendCore ( Hash , input ) ;
29+
30+ public uint Compute ( ReadOnlySpan < byte > input )
31+ => _currentAdler = AppendCore ( 1 , input ) ;
32+
33+ private static uint AppendCore ( uint adler , ReadOnlySpan < byte > input )
34+ => libdeflate_adler32 ( adler , MemoryMarshal . GetReference ( input ) , ( nuint ) input . Length ) ;
35+ }
36+ }
You can’t perform that action at this time.
0 commit comments