Verify package integrity using Subresource Integrity (SRI) hashes.
npm packages include integrity strings in the format:
algorithm-base64hash (e.g. sha512-abc123...).
Summary
Functions
Get the algorithm used in an SRI string.
Compute the SHA-256 SRI integrity string for binary data.
Compute the SHA-512 SRI integrity string for binary data.
Parse an SRI string into {algorithm, hash} tuple.
Verify data against an SRI integrity string.
Functions
Get the algorithm used in an SRI string.
Compute the SHA-256 SRI integrity string for binary data.
Compute the SHA-512 SRI integrity string for binary data.
Parse an SRI string into {algorithm, hash} tuple.
Verify data against an SRI integrity string.
Returns :ok if the hash matches, {:error, :integrity_mismatch} otherwise.
Returns :ok for empty integrity strings (no verification).