public function encode($id, $type = '')
    {
        if (!isset($this->_keys[$type])) {
            if ($this->_key === null) {
                $this->_key = $this->crypt->getDerivedKey('secint');
            }

            $this->_keys[$type] = md5($this->_key . $type, true);
        }

        while (true) {
            $rand = mt_rand() & 0xFFFF0000;
            $r = base64_encode(mcrypt_encrypt(MCRYPT_XTEA, $this->_keys[$type], pack('VV', $id, $rand), MCRYPT_MODE_ECB));
            if (strcspn($r, '+/') === 12) {
                return substr($r, 0, -1);
            }
        }

        return $id;
    }
public function encode($id, $type = '')
    {
        if (!isset($this->_keys[$type])) {
            if ($this->_key === null) {
                $this->_key = $this->crypt->getDerivedKey('secint');
            }

            $this->_keys[$type] = md5($this->_key . $type, true);
        }

        while (true) {
            $rand = mt_rand() & 0xFFFF0000;
            $r = base64_encode(mcrypt_encrypt(MCRYPT_XTEA, $this->_keys[$type], pack('VV', $id, $rand), MCRYPT_MODE_ECB));
            if (strcspn($r, '+/') === 12) {
                return substr($r, 0, -1);
            }
        }

        return $id;
    }
public function encode ( $ id , $ type = '' ) { if ( ! isset ( $ this -> _keys [ $ type ] ) ) { if ( $ this -> _key === null ) { $ this -> _key = $ this -> crypt -> getDerivedKey ( 'secint' ) ; } $ this -> _keys [ $ type ] = md5 ( $ this -> _key . $ type , true ) ; } while ( true ) { $ rand = mt_rand ( ) & 0xFFFF0000 ; $ r = base64_encode ( mcrypt_encrypt ( MCRYPT_XTEA , $ this -> _keys [ $ type ] , pack ( 'VV' , $ id , $ rand ) , MCRYPT_MODE_ECB ) ) ; if ( strcspn ( $ r , '+/' ) === 12 ) { return substr ( $ r , 0 , - 1 ) ; } } return $ id ; }
Encodes a variable number of parameters to generate a hash.

@param int    $id
@param string $type

@return string the generated hash
Encodes a variable number of parameters to generate a hash .