CheckedData

Files CCore/inc/net/CheckedData.h CCore/src/net/CheckedData.cpp

The class CheckedData is useful for net testing. You can fill a data payload with checked random data and verify its integrity.


class CheckedData
 {
   PlatformRandom random;
   uint8 start_sum;

  public:
  
   CheckedData();
    
   ulen getLen(ulen max_len);
    
   bool fill(PtrLen<uint8> data); 
    
   bool check(PtrLen<const uint8> data) const; // random is not used
 };

The method getLen() selects the random length from 2 to max_len. It should be > 2 . If the max_len <= 2, the max_len is always returned.

fill() fills the given byte range with checked random data. It is expected, the range lengtn is >= 2 . Otherwise, the method does nothing and returns false.

check() checks the data range and returns true, if it is correct. random is not used in this method, so this method is multi-thread safe.