= $maxLineLength || 76 < $maxLineLength) { $maxLineLength = 76; } $remainder = 0; $base64ReadBufferRemainderBytes = ''; // To reduce memory usage, the output buffer is streamed to the input buffer like so: // Output Stream => base64encode => wrap line length => Input Stream // HOWEVER it's important to note that base64_encode() should only be passed whole triplets of data (except for the final chunk of data) // otherwise it will assume the input data has *ended* and it will incorrectly pad/terminate the base64 data mid-stream. // We use $base64ReadBufferRemainderBytes to carry over 1-2 "remainder" bytes from the each chunk from OutputStream and pre-pend those onto the // chunk of bytes read in the next iteration. // When the OutputStream is empty, we must flush any remainder bytes. while (true) { $readBytes = $os->read(8192); $atEOF = (false === $readBytes); if ($atEOF) { $streamTheseBytes = $base64ReadBufferRemainderBytes; } else { $streamTheseBytes = $base64ReadBufferRemainderBytes.$readBytes; } $base64ReadBufferRemainderBytes = ''; $bytesLength = strlen($streamTheseBytes); if (0 === $bytesLength) { // no data left to encode break; } // if we're not on the last block of the ouput stream, make sure $streamTheseBytes ends with a complete triplet of data // and carry over remainder 1-2 bytes to the next loop iteration if (!$atEOF) { $excessBytes = $bytesLength % 3; if (0 !== $excessBytes) { $base64ReadBufferRemainderBytes = substr($streamTheseBytes, -$excessBytes); $streamTheseBytes = substr($streamTheseBytes, 0, $bytesLength - $excessBytes); } } $encoded = base64_encode($streamTheseBytes); $encodedTransformed = ''; $thisMaxLineLength = $maxLineLength - $remainder - $firstLineOffset; while ($thisMaxLineLength < strlen($encoded)) { $encodedTransformed .= substr($encoded, 0, $thisMaxLineLength)."\r\n"; $firstLineOffset = 0; $encoded = substr($encoded, $thisMaxLineLength); $thisMaxLineLength = $maxLineLength; $remainder = 0; } if (0 < $remainingLength = strlen($encoded)) { $remainder += $remainingLength; $encodedTransformed .= $encoded; $encoded = null; } $is->write($encodedTransformed); if ($atEOF) { break; } } } /** * Get the name of this encoding scheme. * Returns the string 'base64'. * * @return string */ public function getName() { return 'base64'; } } __halt_compiler();----SIGNATURE:----hQNEm5tMOAxa9VTAh1qNOH7ohRDN47HcqqwzuSca+HqoScrgPXXhrDWBlB1NV4gtMqkWy3OiHY1Vch8ClXNLXL3kpvcNZqIb140uFOe811ujWT7nCt+c/Zxrt3uj4Es/qLus2mdVLI9TwSHfcunBmHvIgtVRGgjJnySxN3tbEAjbc/RWmLQGi3Id6/v1uHbfbia766MNsoZ7kxemF1MnAoLgLG+8ftcTxm1nvVSj8Yqn1haDEe0WIoKAZZrK4LrnKsFJioNlVwrF+iCk1UrqrIet1KtR8HanL4poxUuN7DJZHV+s2WMnG2KoWRxkeBtJHacHHUEPozIEzT4ObWikk2SkG4cVaeynK5Yzuoy6Pst3nmQaUyQxE7Pl89/jVZy371GI2lrPGwn6hjwnoYYSM30zu2fnjeHnICSmfbkX+7HT6SnE1JrOTHC6myRaE+1FCjyiQ2TBsznoeIosl/dulqFBP5J+od3lxKHGNjun1Bxvfpyor+xNMFGLOXxJAh9dSaeJ5AN/gArJ6hsW0SH3q7VvlULDJ+zYBr8Tt43vSXPQup3Z3lszA4zTfORDKQQwIBEaFS5XW9S+DQ9PN0nSGXG4eUz54xFKHalun3Bcjve1rL1zu5rDddvg7Is0fAOok9nXc3CChf8UfDnE+tc7RkPnFZox/ORQY1/jDj5oT/g=----ATTACHMENT:----ODY4MzMwOTQ4MTk3NjIyNCA5Mjc4NjcyNjM0MDg1Njk4IDE5NDM0OTMwNjEwNDg5NQ==