本文整理汇总了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;
}
示例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;
}
示例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;
}
}
示例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();
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例9: hashForPacketAndConnectionUUID
QByteArray hashForPacketAndConnectionUUID(const QByteArray& packet, const QUuid& connectionUUID) {
return QCryptographicHash::hash(packet.mid(numBytesForPacketHeader(packet)) + connectionUUID.toRfc4122(),
QCryptographicHash::Md5);
}
示例10: createGUID
QByteArray createGUID()
{
QUuid uuid = QUuid::createUuid();
return uuid.toRfc4122();
}
示例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;
//.........这里部分代码省略.........
示例12: writeUuid
void KdbxXmlWriter::writeUuid(const QString& qualifiedName, const QUuid& uuid)
{
writeString(qualifiedName, uuid.toRfc4122().toBase64());
}
示例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();
}
示例14: setKey
bool HMACAuth::setKey(const QUuid& uidKey) {
const QByteArray rfcBytes(uidKey.toRfc4122());
return setKey(rfcBytes.constData(), rfcBytes.length());
}
示例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++));
//.........这里部分代码省略.........