Integrity
Motivation
Ensuring event data remains uncorrupted during processing.
How it works
Integrity uses cryptographic hashes to guarantee data integrity.
Options
The following options are available to control Integrity:
integrity.Enable
: Enable integrity checks.import ( "github.com/docker/go-events/integrity" ) func main() { integrity.Enable() }
Example:
// integrity.Enable() is called before any events are processed // Ensures integrity checks are performed on all events.
integrity.Disable
: Disable integrity checks.import ( "github.com/docker/go-events/integrity" ) func main() { integrity.Disable() }
Example:
// integrity.Disable() is called before any events are processed. // Disables integrity checks for all events.
integrity.HashingAlgorithm
: Specifies the hashing algorithm used.import ( "github.com/docker/go-events/integrity" ) func main() { integrity.HashingAlgorithm = integrity.SHA256 }
Example:
// integrity.HashingAlgorithm = integrity.SHA256 is called before any events are processed. // Sets the hashing algorithm to SHA256.
integrity.Checksum
: Returns a checksum value for a given byte array.import ( "github.com/docker/go-events/integrity" ) func main() { data := []byte("hello world") checksum := integrity.Checksum(data) // ... }
Example:
// integrity.Checksum(data) is used to calculate the checksum of the data. // It can be used to verify data integrity.
integrity.Verify
: Verifies the integrity of a given byte array against a checksum.import ( "github.com/docker/go-events/integrity" ) func main() { data := []byte("hello world") checksum := integrity.Checksum(data) verified := integrity.Verify(data, checksum) // ... }
Example:
// integrity.Verify(data, checksum) is used to verify the integrity of the data. // It returns true if the data is intact and false if it has been corrupted.