qTox
Version: nightly | Commit: bc751c8e1cac455f9690654fcfe0f560d2d7dfdd
|
Go to the documentation of this file.
27 #include <QRegularExpression>
33 #define NOSPAM_BYTES 4
34 #define CHECKSUM_BYTES 2
36 #define NOSPAM_HEX_CHARS (2 * NOSPAM_BYTES)
37 #define CHECKSUM_HEX_CHARS (2 * CHECKSUM_BYTES)
38 #define TOXID_HEX_CHARS (2 * TOX_ADDRESS_SIZE)
86 toxId = QByteArray::fromHex(
id.toLatin1());
88 assert(!
"ToxId constructed with invalid length string");
120 QByteArray tmpId(
reinterpret_cast<const char*
>(rawId), len);
127 if (rawId.length() == TOX_ADDRESS_SIZE &&
isToxId(rawId.toHex().toUpper())) {
128 toxId = QByteArray(rawId);
130 assert(!
"ToxId constructed with invalid input");
131 toxId = QByteArray();
162 return toxId.toHex().toUpper();
180 return reinterpret_cast<const uint8_t*
>(
toxId.constData());
192 auto const pkBytes =
toxId.left(TOX_PUBLIC_KEY_SIZE);
193 if (pkBytes.isEmpty()) {
196 return ToxPk{pkBytes};
206 if (
toxId.length() == TOX_ADDRESS_SIZE) {
241 if (
toxId.length() != TOX_ADDRESS_SIZE) {
247 QByteArray data =
toxId.left(size);
251 for (
int i = 0; i < size; i++) {
252 calculated[i % 2] = calculated[i % 2] ^ data[i];
255 return calculated == checksum;
bool operator!=(const ToxId &other) const
Compares the inequality of the Public Key.
QString toString() const
Returns the Tox ID converted to QString. Is equal to getPublicKey() if the Tox ID was constructed fro...
QString getNoSpamString() const
Returns the NoSpam value converted to QString.
void constructToxId(const QByteArray &rawId)
void clear()
Clears all elements of the Tox ID.
static const QRegularExpression ToxIdRegEx
bool isValid() const
Check it it's a valid Tox ID by verifying the checksum.
const uint8_t * getBytes() const
Gets the ToxID as bytes, convenience function for toxcore interface.
ToxId()
The default constructor. Creates an empty Tox ID.
static bool isToxId(const QString &id)
Check, that id is probably a valid Tox ID.
ToxPk getPublicKey() const
Gets the Public Key part of the ToxID.
This class represents a Tox Public Key, which is a part of Tox ID.
This class represents a Tox ID.
bool operator==(const ToxId &other) const
Compares the equality of the Public Key.
static bool isValidToxId(const QString &id)
Check, that id is a valid Tox ID.