Yngvarr

Generation

generate functionSat, 07 Jan 2023

gzencode and stream http archive

function stream_gz_encode($data, $compressed_size) { $size = strlen($data); $crc = crc32($data); $data = gzencode($data, 9); $data = substr_replace($data, pack('V', $crc), -8, 4); $data = substr_replace($data, pack('V', $size), -4, 4); $compressed_size += strlen($data); printf('%s%s%s%s%s', substr($data, 0, 4), pack('V', $crc), pack('V', $size), pack('v', strlen($data) - 12), substr($data, -(strlen($data) - 12)) ); }

Questions about programming?Chat with your personal AI assistant