public static function generateFilteredKey($definition, $masterKey) {
        $cipher = mcrypt_module_open(MCRYPT_RIJNDAEL_128, '', MCRYPT_MODE_CBC, '');
        $ivSize = mcrypt_enc_get_iv_size($cipher);
        $iv = mcrypt_create_iv($ivSize, MCRYPT_RAND);
        
        $definitionWithPading = self::_pad(json_encode($definition),16);
    
        if (mcrypt_generic_init($cipher, $masterKey, $iv) != -1) {
            $cipherText = mcrypt_generic($cipher,$definitionWithPading);
            mcrypt_generic_deinit($cipher);
            $encrypted = sprintf("%s-%s",bin2hex($iv),bin2hex($cipherText)); 
            
            return $encrypted;
        }
    }