Q48: What is Subresource Integrity (SRI) and how does Node.js crypto generate SRI hashes?
Subresource Integrity (SRI) allows security systems to verify that fetched resources (such as scripts or assets) have not been manipulated. Node.js generates SRI hashes by hashing raw file content using cryptographic algorithms like SHA-384 or SHA-512 and encoding the result in base64 prefixed with the algorithm identifier (e.g., sha384-<base64-hash>).
Key Takeaways
- SRI guarantees file integrity by comparing cryptographic hashes against expectations.
- Generated in Node.js via
crypto.createHash('sha384').update(data).digest('base64').
Knowledge Check
What standard encoding format is used for SRI cryptographic hash digest strings?