Get your own Node server
const crypto = require('crypto');

// Simulate processing a large file in chunks
function processLargeDataIncrementally() {
  // Create a hash object
  const hash = crypto.createHash('sha256');
  
  // Simulate reading data in chunks
  const totalChunks = 10;
  
  console.log(`Processing data in ${totalChunks} chunks...`);
  
  for (let i = 0; i < totalChunks; i++) {
    // In a real scenario, this would be data read from a file or stream
    const chunk = `Chunk ${i + 1} of data with some random content: ${crypto.randomBytes(10).toString('hex')}`;
    
    console.log(`Processing chunk ${i + 1}/${totalChunks}, size: ${chunk.length} bytes`);
    
    // Update the hash with this chunk
    hash.update(chunk);
  }
  
  // Calculate final hash after all chunks are processed
  const finalHash = hash.digest('hex');
  console.log('Final SHA-256 hash:', finalHash);
}

// Run the example
processLargeDataIncrementally();

              
Processing data in 10 chunks...
Processing chunk 1/10, size: 68 bytes
Processing chunk 2/10, size: 68 bytes
Processing chunk 3/10, size: 68 bytes
Processing chunk 4/10, size: 68 bytes
Processing chunk 5/10, size: 68 bytes
Processing chunk 6/10, size: 68 bytes
Processing chunk 7/10, size: 68 bytes
Processing chunk 8/10, size: 68 bytes
Processing chunk 9/10, size: 68 bytes
Processing chunk 10/10, size: 68 bytes
Final SHA-256 hash: 1a2b3c4d5e6f7a8b9c0d1e2f3a4b5c6d7e8f9a0b1c2d3e4f5a6b7c8d9e0f1a2b3