Data integrity means that data or a message remains accurate and unaltered during transmission or storage. A browser request can be changed by network faults or interception, while a database record can be damaged or modified. Integrity is distinct from authentication, confidentiality, and nonrepudiation: it answers whether the data changed, not who sent it or who can read it. section 4.1
Choose the protection according to the failure or attack you must detect:
- A cryptographic hash such as SHA-2 or SHA-3 produces a fixed-size, deterministic value. Comparing the stored and recalculated values detects accidental corruption, but an attacker who changes both the data and hash can evade detection. section 4.7 section 4.8
- A message authentication code, commonly HMAC, combines the message with a secret shared by sender and receiver. A matching value supports both integrity and authenticity because an attacker cannot generate a valid value without the key. section 4.5 section 4.7
- JWS packages signed data, integrity information, and signing metadata in one file. The recipient can verify the creator and detect alteration, while the readable header and payload remain unencrypted. section 11.4.3
Refund processing
Suppose a warehouse application sends refunds.json to a payments service. A plain SHA-256 checksum can reveal accidental corruption, but an attacker can replace both files and alter a refund amount. HMAC lets the payments service reject modified data because the attacker lacks the shared secret. JWS can package the refund payload and its signature into refunds.jws; changing the secret or file content causes verification to fail and the payment service to reject the file. section 4.7 section 11.4.3
Figure 4.1 A typical high-level e-commerce architecture. Customers place orders using ACME’s web applications, which call the Payments, Inc. credit card API to collect payment while processing an order.
Trace integrity requirements across the browser, e-commerce application, and payment API in a typical request flow. section 4.1

















