title: CRC calculation reduction
body: <p>I have one math and programming related question about CRC calculations, to avoid recompute full CRC for a block when you must change only a small portion of it.</p>
  
  <p>My problem is the following: I have a 1K block of 4 byte structures, each one representing a data field. The full 1K block has a CRC16 block at the end, computed over the full 1K. When I have to change only a 4 byte structure, I should recompute the CRC of the full block but I'm searching for a more efficient solution to this problem. Something where:</p>
  
  <ol>
  <li><p>I take the full 1K block current CRC16</p></li>
  <li><p>I compute something on the old 4 byte block</p></li>
  <li><p>I "subtract" something obtained at step 2 from the full 1K CRC16</p></li>
  <li><p>I compute something on the new 4 byte block</p></li>
  <li><p>I "add" something obtained at step 4 to the result obtained at step 3</p></li>
  </ol>
  
  <p>To summarize, I am thinking about something like this:</p>
  
  <p>CRC(new-full) = [CRC(old-full) - CRC(block-old) + CRC(block-new)]</p>
  
  <p>But I'm missing the math behind and what to do to obtain this result, considering also a "general formula".</p>
  
  <p>Thanks in advance.</p>