function _generate_xor($length, &$iv)
    {
        $xor = '';
        $block_size = $this->block_size;
        $num_blocks = floor(($length + ($block_size - 1)) / $block_size);
        for ($i = 0; $i < $num_blocks; $i++) {
            $xor.= $iv;
            for ($j = 4; $j <= $block_size; $j+=4) {
                $temp = substr($iv, -$j, 4);
                switch ($temp) {
                    case "\xFF\xFF\xFF\xFF":
                        $iv = substr_replace($iv, "\x00\x00\x00\x00", -$j, 4);
                        break;
                    case "\x7F\xFF\xFF\xFF":
                        $iv = substr_replace($iv, "\x80\x00\x00\x00", -$j, 4);
                        break 2;
                    default:
                        extract(unpack('Ncount', $temp));
                        $iv = substr_replace($iv, pack('N', $count + 1), -$j, 4);
                        break 2;
                }
            }
        }

        return $xor;
    }
function _generate_xor($length, &$iv)
    {
        $xor = '';
        $block_size = $this->block_size;
        $num_blocks = floor(($length + ($block_size - 1)) / $block_size);
        for ($i = 0; $i < $num_blocks; $i++) {
            $xor.= $iv;
            for ($j = 4; $j <= $block_size; $j+=4) {
                $temp = substr($iv, -$j, 4);
                switch ($temp) {
                    case "\xFF\xFF\xFF\xFF":
                        $iv = substr_replace($iv, "\x00\x00\x00\x00", -$j, 4);
                        break;
                    case "\x7F\xFF\xFF\xFF":
                        $iv = substr_replace($iv, "\x80\x00\x00\x00", -$j, 4);
                        break 2;
                    default:
                        extract(unpack('Ncount', $temp));
                        $iv = substr_replace($iv, pack('N', $count + 1), -$j, 4);
                        break 2;
                }
            }
        }

        return $xor;
    }
function _generate_xor ( $ length , & $ iv ) { $ xor = '' ; $ block_size = $ this -> block_size ; $ num_blocks = floor ( ( $ length + ( $ block_size - 1 ) ) / $ block_size ) ; for ( $ i = 0 ; $ i < $ num_blocks ; $ i ++ ) { $ xor .= $ iv ; for ( $ j = 4 ; $ j <= $ block_size ; $ j += 4 ) { $ temp = substr ( $ iv , - $ j , 4 ) ; switch ( $ temp ) { case "\xFF\xFF\xFF\xFF" : $ iv = substr_replace ( $ iv , "\x00\x00\x00\x00" , - $ j , 4 ) ; break ; case "\x7F\xFF\xFF\xFF" : $ iv = substr_replace ( $ iv , "\x80\x00\x00\x00" , - $ j , 4 ) ; break 2 ; default : extract ( unpack ( 'Ncount' , $ temp ) ) ; $ iv = substr_replace ( $ iv , pack ( 'N' , $ count + 1 ) , - $ j , 4 ) ; break 2 ; } } } return $ xor ; }
Generate CTR XOR encryption key

Encrypt the output of this and XOR it against the ciphertext / plaintext to get the
plaintext / ciphertext in CTR mode.

@see Crypt_Rijndael::decrypt()
@see Crypt_Rijndael::encrypt()
@access public
@param Integer $length
@param String $iv
Generate CTR XOR encryption key