当前位置: 首页>>代码示例>>C++>>正文


C++ QByteArray::toBase64方法代码示例

本文整理汇总了C++中QByteArray::toBase64方法的典型用法代码示例。如果您正苦于以下问题:C++ QByteArray::toBase64方法的具体用法?C++ QByteArray::toBase64怎么用?C++ QByteArray::toBase64使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QByteArray的用法示例。


在下文中一共展示了QByteArray::toBase64方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: imageToHash

QString QgsRenderChecker::imageToHash( QString theImageFile )
{
  QImage myImage;
  myImage.load( theImageFile );
  QByteArray myByteArray;
  QBuffer myBuffer( &myByteArray );
  myImage.save( &myBuffer, "PNG" );
  QString myImageString = QString::fromUtf8( myByteArray.toBase64().data() );
  QCryptographicHash myHash( QCryptographicHash::Md5 );
  myHash.addData( myImageString.toUtf8() );
  return myHash.result().toHex().constData();
}
开发者ID:namhh,项目名称:Quantum-GIS,代码行数:12,代码来源:qgsrenderchecker.cpp

示例2: toByteArray

QByteArray IconFactory::toByteArray(const QIcon &icon) {
  QByteArray array;
  QBuffer buffer(&array);
  buffer.open(QIODevice::WriteOnly);

  QDataStream out(&buffer);
  out.setVersion(QDataStream::Qt_4_7);
  out << icon;

  buffer.close();
  return array.toBase64();
}
开发者ID:keinkurt,项目名称:rssguard,代码行数:12,代码来源:iconfactory.cpp

示例3: generateKey

/*!
	\internal
 */
QByteArray WebSocket::generateKey() const
{
	QByteArray key;

	for (int i = 0; i < 4; ++i)
	{
		quint32 tmp = generateRandomNumber();
		key.append(static_cast<const char *>(static_cast<const void *>(&tmp)), sizeof(quint32));
	}

	return key.toBase64();
}
开发者ID:Jasonic,项目名称:IanniX,代码行数:15,代码来源:websocket.cpp

示例4: messageFromClient

void Server::messageFromClient(QByteArray message,QString client){
    qDebug()<<ENCAPS(tr("[server] incoming"))<<message.toBase64()<<ENCAPS(tr("from"))<<client;
    QString header;
    QDataStream stream(message);
    stream >> header;
    qDebug()<<header;
    if(0==header.compare("SET_VELOCITY")){
        qDebug()<<ENCAPS(tr("Got velocity data!"));
        int i;
        stream >> i;
        stream >> spaceObjects[client][i].velocity;
    }
开发者ID:datenwolf,项目名称:YAFANWEBATPC,代码行数:12,代码来源:server.cpp

示例5: startAuthentication

bool LoginJobPrivate::startAuthentication()
{
  //SASL authentication
  if ( !initSASL() ) {
    q->setError( LoginJob::UserDefinedError );
    q->setErrorText( i18n( "Login failed, client cannot initialize the SASL library." ) );
    return false;
  }

  authState = LoginJobPrivate::Authenticate;
  const char *out = 0;
  uint outlen = 0;
  const char *mechusing = 0;

  int result = sasl_client_new( "imap", m_session->hostName().toLatin1(), 0, 0, callbacks, 0, &conn );
  if ( result != SASL_OK ) {
    kDebug() << "sasl_client_new failed with:" << result;
    q->setError( LoginJob::UserDefinedError );
    q->setErrorText( QString::fromUtf8( sasl_errdetail( conn ) ) );
    return false;
  }

  do {
    result = sasl_client_start( conn, authMode.toLatin1(), &client_interact, capabilities.contains( "SASL-IR" ) ? &out : 0, &outlen, &mechusing );

    if ( result == SASL_INTERACT ) {
      if ( !sasl_interact() ) {
        sasl_dispose( &conn );
        q->setError( LoginJob::UserDefinedError ); //TODO: check up the actual error
        return false;
      }
    }
  } while ( result == SASL_INTERACT );

  if ( result != SASL_CONTINUE && result != SASL_OK ) {
    kDebug() << "sasl_client_start failed with:" << result;
    q->setError( LoginJob::UserDefinedError );
    q->setErrorText( QString::fromUtf8( sasl_errdetail( conn ) ) );
    sasl_dispose( &conn );
    return false;
  }

  QByteArray tmp = QByteArray::fromRawData( out, outlen );
  QByteArray challenge = tmp.toBase64();

  if ( challenge.isEmpty() ) {
    tags << sessionInternal()->sendCommand( "AUTHENTICATE", authMode.toLatin1() );
  } else {
    tags << sessionInternal()->sendCommand( "AUTHENTICATE", authMode.toLatin1() + ' ' + challenge );
  }

  return true;
}
开发者ID:pvuorela,项目名称:kcalcore,代码行数:53,代码来源:loginjob.cpp

示例6: variantEncode

QVariant SettingsManager::variantEncode(const QVariant &v) const
{
    if (v.type() == QVariant::ByteArray) {
        QByteArray data = v.toByteArray();
        data = data.toBase64();

        return data;
    }
    else {
        return v;
    }
}
开发者ID:ahmadsl,项目名称:Saaghar,代码行数:12,代码来源:settingsmanager.cpp

示例7: encrypt

//=============================================================================
//=============================================================================
QString Crypt::encrypt(QString str)
{
  FUNC_DEBUG;  
  if (_key.isEmpty() || str.isEmpty()) { return QString(); }
  
  QByteArray baEncrypt = str.toLatin1();
  for (int i = 0; i < baEncrypt.count(); i++) {
    baEncrypt[i] = baEncrypt.at(i) ^ _key.at(i % _key.size());
  }
  baEncrypt = qCompress(baEncrypt,9);
  return QString(baEncrypt.toBase64());
}
开发者ID:caidongyun,项目名称:AutoPutty,代码行数:14,代码来源:crypt.cpp

示例8: calculateResponse

QByteArray QAuthenticatorPrivate::calculateResponse(const QByteArray &requestMethod, const QByteArray &path)
{
    QByteArray response;
    const char *methodString = 0;
    switch(method) {
    case QAuthenticatorPrivate::None:
        methodString = "";
        phase = Done;
        break;
    case QAuthenticatorPrivate::Plain:
        response = '\0' + user.toUtf8() + '\0' + password.toUtf8();
        phase = Done;
        break;
    case QAuthenticatorPrivate::Basic:
        methodString = "Basic ";
        response = user.toLatin1() + ':' + password.toLatin1();
        response = response.toBase64();
        phase = Done;
        break;
    case QAuthenticatorPrivate::Login:
        if (challenge.contains("VXNlciBOYW1lAA==")) {
            response = user.toUtf8().toBase64();
            phase = Phase2;
        } else if (challenge.contains("UGFzc3dvcmQA")) {
            response = password.toUtf8().toBase64();
            phase = Done;
        }
        break;
    case QAuthenticatorPrivate::CramMd5:
        break;
    case QAuthenticatorPrivate::DigestMd5:
        methodString = "Digest ";
        response = digestMd5Response(challenge, requestMethod, path);
        phase = Done;
        break;
    case QAuthenticatorPrivate::Ntlm:
        methodString = "NTLM ";
        if (challenge.isEmpty()) {
            response = qNtlmPhase1().toBase64();
            if (user.isEmpty())
                phase = Done;
            else
                phase = Phase2;
        } else {
            response = qNtlmPhase3(this, QByteArray::fromBase64(challenge)).toBase64();
            phase = Done;
        }

        break;
    }
    return QByteArray(methodString) + response;
}
开发者ID:Suneal,项目名称:qt,代码行数:52,代码来源:qauthenticator.cpp

示例9: createSecurityToken

// static
bool Sandbox::createSecurityToken(const QString& canonicalPath,
                                  bool isDirectory) {
    if (sDebug) {
        qDebug() << "createSecurityToken" << canonicalPath << isDirectory;
    }
    if (!enabled()) {
        return false;
    }
    QMutexLocker locker(&s_mutex);
    if (s_pSandboxPermissions == NULL) {
        return false;
    }

#ifdef Q_OS_MAC
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
    CFURLRef url = CFURLCreateWithFileSystemPath(
            kCFAllocatorDefault, QStringToCFString(canonicalPath),
            kCFURLPOSIXPathStyle, isDirectory);
    if (url) {
        CFErrorRef error = NULL;
        CFDataRef bookmark = CFURLCreateBookmarkData(
                kCFAllocatorDefault, url,
                kCFURLBookmarkCreationWithSecurityScope, nil, nil, &error);
        CFRelease(url);
        if (bookmark) {
            QByteArray bookmarkBA = QByteArray(
                    reinterpret_cast<const char*>(CFDataGetBytePtr(bookmark)),
                    CFDataGetLength(bookmark));

            QString bookmarkBase64 = QString(bookmarkBA.toBase64());

            s_pSandboxPermissions->set(keyForCanonicalPath(canonicalPath),
                                       bookmarkBase64);
            CFRelease(bookmark);
            return true;
        } else {
            if (sDebug) {
                qDebug() << "Failed to create security-scoped bookmark for" << canonicalPath;
                if (error != NULL) {
                    qDebug() << "Error:" << CFStringToQString(CFErrorCopyDescription(error));
                }
            }
        }
    } else {
        if (sDebug) {
            qDebug() << "Failed to create security-scoped bookmark URL for" << canonicalPath;
        }
    }
#endif
#endif
    return false;
}
开发者ID:flashpig,项目名称:mixxx,代码行数:53,代码来源:sandbox.cpp

示例10: messageFromServer

void ClientWidget::messageFromServer(QByteArray message){
    qDebug()<<ENCAPS(tr("incoming"))<<message.toBase64();
    QString header;
    QDataStream stream(message);
    stream >> header;
    qDebug()<<header;
    if(0==header.compare("SIMULATION_UPDATE_DATA")){
        qDebug()<<ENCAPS(tr("Got simulation data!"));
        int size,i;
        stream >> size;
        stream >> i;
        stream >> me;
    }
开发者ID:datenwolf,项目名称:YAFANWEBATPC,代码行数:13,代码来源:clientwidget.cpp

示例11: write

QString BaseStateAbstract::write(QString val, bool compress)
{
    QString ret;
    QByteArray data = val.toUtf8();

    if (compress)
        data = qCompress(data,9).toBase64().prepend(COMPRESSED_MARKER); // prepending # to signify the string is compressed
    else
        data = data.toBase64();

    ret = QString::fromUtf8(data.constData(), data.size());
    return ret;
}
开发者ID:metrodango,项目名称:pip3line,代码行数:13,代码来源:basestateabstract.cpp

示例12: serialiseLeaves

void unitFaceModel::serialiseLeaves(const QList<QList<QList<int> > >& allLeaves)
{
    QByteArray byteArray;
    QBuffer writeBuffer(&byteArray);
    writeBuffer.open(QIODevice::WriteOnly);
    QDataStream out(&writeBuffer);

    out << allLeaves;

    writeBuffer.close();

    serialisedLeaves = QString(byteArray.toBase64());
}
开发者ID:UnforeseenOcean,项目名称:face,代码行数:13,代码来源:tldface.cpp

示例13: serializeItems

 QString RecentItemsModel::serializeItems() {
     // historical reasons to have QQueue here
     // now only thing left is to be backward compatible
     QQueue<QString> items;
     for (auto &kv: m_LRUcache.data()) {
         items.enqueue(kv.first);
     }
     Q_ASSERT(m_LRUcache.size() <= m_MaxRecentItems);
     QByteArray raw;
     QDataStream ds(&raw, QIODevice::WriteOnly);
     ds << items;
     return QString::fromLatin1(raw.toBase64());
 }
开发者ID:Ribtoks,项目名称:xpiks,代码行数:13,代码来源:recentitemsmodel.cpp

示例14:

QByteArray AuthHelper::encodeBasicB64Auth( const QString& aUsername, const QString& aPassword ) const
{
    FUNCTION_CALL_TRACE;

    QByteArray in;

    in.append( aUsername );
    in.append( ':' );
    in.append( aPassword );

    return in.toBase64();

}
开发者ID:kavuri,项目名称:buteo-syncml,代码行数:13,代码来源:AuthHelper.cpp

示例15: saveState

    void TorrentActivity::saveState(KSharedConfigPtr cfg)
    {
        search_bar->saveState(cfg);
        group_view->saveState(cfg);
        group_switcher->saveState(cfg);
        qm->saveState(cfg);
        tool_views->saveState(cfg, "TorrentActivityBottomTabBar");
        magnet_view->saveState(cfg);

        KConfigGroup g = cfg->group("TorrentActivitySplitters");
        if (vsplit)
        {
            QByteArray data = vsplit->saveState();
            g.writeEntry("vsplit", data.toBase64());
        }

        if (hsplit)
        {
            QByteArray data = hsplit->saveState();
            g.writeEntry("hsplit", data.toBase64());
        }
    }
开发者ID:biwin,项目名称:ktorrent,代码行数:22,代码来源:torrentactivity.cpp


注:本文中的QByteArray::toBase64方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。