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


C++ QUuid::toRfc4122方法代码示例

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


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

示例1: writeSourceID

void NLPacket::writeSourceID(const QUuid& sourceID) const {
    Q_ASSERT(!NON_SOURCED_PACKETS.contains(_type));
    
    auto offset = Packet::totalHeaderSize(isPartOfMessage()) + sizeof(PacketType) + sizeof(PacketVersion);
    memcpy(_packet.get() + offset, sourceID.toRfc4122().constData(), NUM_BYTES_RFC4122_UUID);
    
    _sourceID = sourceID;
}
开发者ID:CryptArc,项目名称:hifi,代码行数:8,代码来源:NLPacket.cpp

示例2: populatePacketHeader

int populatePacketHeader(char* packet, PacketType type, const QUuid& connectionUUID) {
    int numTypeBytes = packArithmeticallyCodedValue(type, packet);
    packet[numTypeBytes] = versionForPacketType(type);
    
    QUuid packUUID = connectionUUID.isNull() ? NodeList::getInstance()->getOwnerUUID() : connectionUUID;
    
    QByteArray rfcUUID = packUUID.toRfc4122();
    memcpy(packet + numTypeBytes + sizeof(PacketVersion), rfcUUID.constData(), NUM_BYTES_RFC4122_UUID);
    
    // return the number of bytes written for pointer pushing
    return numTypeBytes + sizeof(PacketVersion) + NUM_BYTES_RFC4122_UUID;
}
开发者ID:BogusCurry,项目名称:hifi,代码行数:12,代码来源:PacketHeaders.cpp

示例3: appendValue

bool OctreePacketData::appendValue(const QUuid& uuid) {
    QByteArray bytes = uuid.toRfc4122();
    if (uuid.isNull()) {
        return appendValue((uint16_t)0); // zero length for null uuid
    } else {
        uint16_t length = bytes.size();
        bool success = appendValue(length);
        if (success) {
            success = appendRawData((const unsigned char*)bytes.constData(), bytes.size());
        }
        return success;
    }
}
开发者ID:Giugiogia,项目名称:hifi,代码行数:13,代码来源:OctreePacketData.cpp

示例4: hashForPacketAndSecret

QByteArray NLPacket::hashForPacketAndSecret(const udt::Packet& packet, const QUuid& connectionSecret) {
    QCryptographicHash hash(QCryptographicHash::Md5);
    
    int offset = Packet::totalHeaderSize(packet.isPartOfMessage()) + sizeof(PacketType) + sizeof(PacketVersion)
        + NUM_BYTES_RFC4122_UUID + NUM_BYTES_MD5_HASH;
    
    // add the packet payload and the connection UUID
    hash.addData(packet.getData() + offset, packet.getDataSize() - offset);
    hash.addData(connectionSecret.toRfc4122());
    
    // return the hash
    return hash.result();
}
开发者ID:CryptArc,项目名称:hifi,代码行数:13,代码来源:NLPacket.cpp

示例5: getUsernameSignature

QByteArray DataServerAccountInfo::getUsernameSignature(const QUuid& connectionToken) {
    auto lowercaseUsername = _username.toLower().toUtf8();
    auto plaintext = lowercaseUsername.append(connectionToken.toRfc4122());

    auto signature = signPlaintext(plaintext);
    if (!signature.isEmpty()) {
        qDebug(networking) << "Returning username" << _username
            << "signed with connection UUID" << uuidStringWithoutCurlyBraces(connectionToken);
    } else {
        qCDebug(networking) << "Error signing username with connection token";
        qCDebug(networking) << "Will re-attempt on next domain-server check in.";
    }

    return signature;
}
开发者ID:PhilipRosedale,项目名称:hifi,代码行数:15,代码来源:DataServerAccountInfo.cpp

示例6: populatePacketHeader

int populatePacketHeader(char* packet, PacketType type, const QUuid& connectionUUID) {
    int numTypeBytes = packArithmeticallyCodedValue(type, packet);
    packet[numTypeBytes] = versionForPacketType(type);
    
    char* position = packet + numTypeBytes + sizeof(PacketVersion);
    
    QUuid packUUID = connectionUUID.isNull() ? NodeList::getInstance()->getSessionUUID() : connectionUUID;
    
    QByteArray rfcUUID = packUUID.toRfc4122();
    memcpy(position, rfcUUID.constData(), NUM_BYTES_RFC4122_UUID);
    position += NUM_BYTES_RFC4122_UUID;
    
    // pack 16 bytes of zeros where the md5 hash will be placed one data is packed
    memset(position, 0, NUM_BYTES_MD5_HASH);
    position += NUM_BYTES_MD5_HASH;
    
    // return the number of bytes written for pointer pushing
    return position - packet;
}
开发者ID:kordero,项目名称:hifi,代码行数:19,代码来源:PacketHeaders.cpp

示例7: createFromName

static QUuid createFromName(const QUuid &ns, const QByteArray &baseData, QCryptographicHash::Algorithm algorithm, int version)
{
    QByteArray hashResult;

    // create a scope so later resize won't reallocate
    {
        QCryptographicHash hash(algorithm);
        hash.addData(ns.toRfc4122());
        hash.addData(baseData);
        hashResult = hash.result();
    }
    hashResult.resize(16); // Sha1 will be too long

    QUuid result = QUuid::fromRfc4122(hashResult);

    result.data3 &= 0x0FFF;
    result.data3 |= (version << 12);
    result.data4[0] &= 0x3F;
    result.data4[0] |= 0x80;

    return result;
}
开发者ID:2gis,项目名称:2gisqt5android,代码行数:22,代码来源:quuid.cpp

示例8: encodeEraseEntityMessage

// NOTE: This version will only encode the portion of the edit message immediately following the
// header it does not include the send times and sequence number because that is handled by the 
// edit packet sender...
bool EntityItemProperties::encodeEraseEntityMessage(const EntityItemID& entityItemID, 
                                            unsigned char* outputBuffer, size_t maxLength, size_t& outputLength) {

    unsigned char* copyAt = outputBuffer;
    uint16_t numberOfIds = 1; // only one entity ID in this message

    if (maxLength < sizeof(numberOfIds) + NUM_BYTES_RFC4122_UUID) {
        qDebug() << "ERROR - encodeEraseEntityMessage() called with buffer that is too small!";
        outputLength = 0;
        return false;
    }
    memcpy(copyAt, &numberOfIds, sizeof(numberOfIds));
    copyAt += sizeof(numberOfIds);
    outputLength = sizeof(numberOfIds);

    QUuid entityID = entityItemID.id;                
    QByteArray encodedEntityID = entityID.toRfc4122();

    memcpy(copyAt, encodedEntityID.constData(), NUM_BYTES_RFC4122_UUID);
    copyAt += NUM_BYTES_RFC4122_UUID;
    outputLength += NUM_BYTES_RFC4122_UUID;

    return true;
}
开发者ID:Schackasawa,项目名称:hifi,代码行数:27,代码来源:EntityItemProperties.cpp

示例9: hashForPacketAndConnectionUUID

QByteArray hashForPacketAndConnectionUUID(const QByteArray& packet, const QUuid& connectionUUID) {
    return QCryptographicHash::hash(packet.mid(numBytesForPacketHeader(packet)) + connectionUUID.toRfc4122(),
                                    QCryptographicHash::Md5);
}
开发者ID:kordero,项目名称:hifi,代码行数:4,代码来源:PacketHeaders.cpp

示例10: createGUID

QByteArray createGUID()
{
    QUuid uuid = QUuid::createUuid();
    return uuid.toRfc4122();
}
开发者ID:pljones,项目名称:JamTaba,代码行数:5,代码来源:main.cpp

示例11: tcp_ping

int tcp_ping(QStringList command) {
    qDebug() << "tcp_ping(" << command.join(" ") << ")" << endl;

    /**
     * Check input
     */
    QTextStream errorStream(stderr);

    if(command.size() != 3 || command.at(0)!="ping" || command.at(1)!="tcp" ) {

        errorStream << "Error: tcp_ping(" << command.join(" ") << ") is no valid call (ping tcp <ip_address> <port> rzv|max|random|default)" << endl;
        return 1;
    }

    QByteArray byteArray;

    /**
     * CIP for "rzv"
     */
    if(command.at(2)=="rzv") {
        qDebug() << "rzv" << endl;

        byteArray.append(QByteArray(42, '\0'));
     }

    /**
     * CIP for "default"
     */
    if(command.at(2)=="default") {
        qDebug() << "default" << endl;

        // Header: request (1), profile (1), version (1), channel (1)
        byteArray.append(QByteArray(4, '\0'));

        // Header: UUID (16)
        QUuid uuid;
        uuid = QUuid::createUuid();
        QByteArray uuid_arr = uuid.toRfc4122();

        for(int j=0; j<16;j++) {

            byteArray.append(uuid_arr.at(j));
        }

        // Header: Empty IP address (4), port number (2), time (8), type (1), size (1)
        byteArray.append(QByteArray(16, '\0'));

        // Contextinformation: type (1), root-CIC (2), size (1)
        byteArray.append(QByteArray(4, '\0'));

        // Application: type (1), size (1)
        byteArray.append(QByteArray(2, '\0'));
     }

    /**
     * CIP for "max"
     */
    if(command.at(2)=="max") {
        qDebug() << "max" << endl;

        // Header: fix
        byteArray.append(QByteArray(34, '\0'));

        // Header: size (1)
        byteArray.append(QByteArray(QByteArray::fromHex("0xff")));
        byteArray.append(QByteArray(255, '\0'));

        // Contextinformation: fix
        byteArray.append(QByteArray(2, '\0'));

        // Contextinformation: size (255)
        byteArray.append(QByteArray(QByteArray::fromHex("0xff")));
        byteArray.append(QByteArray(255*2, '\0'));

        // Application Data: fix
        byteArray.append(QByteArray(0, '\0'));

        // Application Data: size (255)
        byteArray.append(QByteArray(QByteArray::fromHex("0xff")));
        byteArray.append(QByteArray(255, '\0'));


     }

    /**
     * CIP for "random"
     */
    if(command.at(2)=="random") {
        qDebug() << "random" << endl;

        QByteArray randValues;
        qsrand(QTime::currentTime().msec());
        for(int i=0; i <= 1064; i++) {
            randValues.append(qFloor(qrand()/CRN_RANDOM_DIVISOR));
        }


        int i = 0;
        quint8 rand;

//.........这里部分代码省略.........
开发者ID:stefanhans,项目名称:ContextRouting,代码行数:101,代码来源:tcp_ping.cpp

示例12: writeUuid

void KdbxXmlWriter::writeUuid(const QString& qualifiedName, const QUuid& uuid)
{
    writeString(qualifiedName, uuid.toRfc4122().toBase64());
}
开发者ID:droidmonkey,项目名称:keepassx_http,代码行数:4,代码来源:KdbxXmlWriter.cpp

示例13: getUsernameSignature

QByteArray DataServerAccountInfo::getUsernameSignature(const QUuid& connectionToken) {
    
        if (!_privateKey.isEmpty()) {
            const char* privateKeyData = _privateKey.constData();
            RSA* rsaPrivateKey = d2i_RSAPrivateKey(NULL,
                                                   reinterpret_cast<const unsigned char**>(&privateKeyData),
                                                   _privateKey.size());
            if (rsaPrivateKey) {
                QByteArray lowercaseUsername = _username.toLower().toUtf8();
                QByteArray usernameWithToken = QCryptographicHash::hash(lowercaseUsername.append(connectionToken.toRfc4122()),
                                                                        QCryptographicHash::Sha256);
                
                QByteArray usernameSignature(RSA_size(rsaPrivateKey), 0);
                unsigned int usernameSignatureSize = 0;
                
                int encryptReturn = RSA_sign(NID_sha256,
                                             reinterpret_cast<const unsigned char*>(usernameWithToken.constData()),
                                             usernameWithToken.size(),
                                             reinterpret_cast<unsigned char*>(usernameSignature.data()),
                                             &usernameSignatureSize,
                                             rsaPrivateKey);
                
                // free the private key RSA struct now that we are done with it
                RSA_free(rsaPrivateKey);

                if (encryptReturn == -1) {
                    qCDebug(networking) << "Error encrypting username signature.";
                    qCDebug(networking) << "Will re-attempt on next domain-server check in.";
                } else {
                    qDebug(networking) << "Returning username" << _username << "signed with connection UUID" << uuidStringWithoutCurlyBraces(connectionToken);
                    return usernameSignature;
                }
                
            } else {
                qCDebug(networking) << "Could not create RSA struct from QByteArray private key.";
                qCDebug(networking) << "Will re-attempt on next domain-server check in.";
            }
        }
    return QByteArray();
}
开发者ID:bwent,项目名称:hifi,代码行数:40,代码来源:DataServerAccountInfo.cpp

示例14: setKey

bool HMACAuth::setKey(const QUuid& uidKey) {
    const QByteArray rfcBytes(uidKey.toRfc4122());
    return setKey(rfcBytes.constData(), rfcBytes.length());
}
开发者ID:AndrewMeadows,项目名称:hifi,代码行数:4,代码来源:HMACAuth.cpp

示例15: offer

int offer(QStringList command) {
    qDebug() << "offer(" << command.join(" ") << ")" << endl;


    /**
     * Debug
     */
    for(int i=0;i<command.size();i++) {
        qDebug() << "command.at(" << i << ")" << command.at(i) << endl;
    }


    /**
     * Check input
     */
    QTextStream errorStream(stderr);

    if(command.size() != 3) {

        errorStream << "Error: offer(" << command.join(" ") << "): No valid number of arguments!" << endl;
        man("usage offer");
        return 1;
    }


    if(command.at(0)!="offer") {

        errorStream << "Error: offer(" << command.join(" ") << "): No valid command!" << endl;
        man("usage offer");
        return 1;
    }

    if(! command.at(2).contains(QRegExp("^(random)$"))) {

        errorStream << "Error: offer(" << command.join(" ") << "): No valid mode!" << endl;
        man("usage offer");
        return 1;
    }


    QByteArray byteArray;

    /**
     * Offer CIP for "random"
     */
    if(command.at(2)=="random") {
        qDebug() << "random" << endl;


        /*
         * Create random CIP
         */



        QByteArray randValues;
        qsrand(QTime::currentTime().msec());

        for(int i=0; i <= 1064; i++) {
            randValues.append((quint8) qFloor(qrand()/CRN_RANDOM_DIVISOR));
        }


        quint8 i = 0;
        quint8 rand;

        // Header: request (1)
        byteArray.append(randValues.at(i++));


        // Header: profile (1)
        byteArray.append(randValues.at(i++));


        // Header: version (1)
        byteArray.append(randValues.at(i++));


        // Header: channel (1)
        byteArray.append(randValues.at(i++));

        // Header: UUID (16)
        QUuid uuid;
        uuid = QUuid::createUuid();
        QByteArray uuid_arr = uuid.toRfc4122();

        for(int j=0; j<16;j++) {

            byteArray.append(uuid_arr.at(j));
        }

        // Header: Empty IP address (4) and port number (2)
        byteArray.append(QByteArray(6, '\0'));

        // Header: time (8)
        byteArray.append(QByteArray(8, '\0'));

        // Header: type (1)
        byteArray.append(randValues.at(i++));

//.........这里部分代码省略.........
开发者ID:stefanhans,项目名称:ContextRouting,代码行数:101,代码来源:main.cpp


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