mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
feat(toxpk): Add 'ToxPk::getPkSize()' method
This commit is contained in:
parent
d351f9e5ec
commit
f5c0d61ae6
|
@ -83,8 +83,8 @@ QString ToxPk::toString() const
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Returns a pointer to the raw key data.
|
* @brief Returns a pointer to the raw key data.
|
||||||
* @return Pointer to the raw key data, which is exactly TOX_PUBLIC_KEY_SIZE bytes
|
* @return Pointer to the raw key data, which is exactly `ToxPk::getPkSize()`
|
||||||
* long. Returns a nullptr if the ToxPk is empty.
|
* bytes long. Returns a nullptr if the ToxPk is empty.
|
||||||
*/
|
*/
|
||||||
const uint8_t* ToxPk::getBytes() const
|
const uint8_t* ToxPk::getBytes() const
|
||||||
{
|
{
|
||||||
|
@ -113,3 +113,12 @@ bool ToxPk::isEmpty() const
|
||||||
{
|
{
|
||||||
return key.isEmpty();
|
return key.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get size of public key in bytes.
|
||||||
|
* @return Size of public key in bytes.
|
||||||
|
*/
|
||||||
|
int ToxPk::getPkSize()
|
||||||
|
{
|
||||||
|
return TOX_PUBLIC_KEY_SIZE;
|
||||||
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@ public:
|
||||||
const uint8_t* getBytes() const;
|
const uint8_t* getBytes() const;
|
||||||
bool isEmpty() const;
|
bool isEmpty() const;
|
||||||
|
|
||||||
|
static int getPkSize();
|
||||||
private:
|
private:
|
||||||
QByteArray key;
|
QByteArray key;
|
||||||
};
|
};
|
||||||
|
|
|
@ -58,7 +58,7 @@ START_TEST(publicKeyTest)
|
||||||
{
|
{
|
||||||
ToxPk pk(testPk);
|
ToxPk pk(testPk);
|
||||||
ck_assert(testPk == pk.getKey());
|
ck_assert(testPk == pk.getKey());
|
||||||
for (int i = 0; i < 32; i++) {
|
for (int i = 0; i < ToxPk::getPkSize(); i++) {
|
||||||
ck_assert(testPkArray[i] == pk.getBytes()[i]);
|
ck_assert(testPkArray[i] == pk.getBytes()[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user