const crypto = require('crypto');
// Create a hash object
const hash = crypto.createHash('sha256');
// Update with common data
hash.update('Common prefix data');
// Create a copy
const hashCopy = hash.copy();
// Update the original hash with more data
hash.update(' with additional data for original');
const originalDigest = hash.digest('hex');
// Update the copy with different data
hashCopy.update(' with different data for copy');
const copyDigest = hashCopy.digest('hex');
console.log('Original hash:', originalDigest);
console.log('Copy hash:', copyDigest);
console.log('Are they different?', originalDigest !== copyDigest);
// This is useful when you want to create multiple hash variations
// from a common starting point, without recalculating the common portion