Skip to content
This repository has been archived by the owner on Feb 12, 2023. It is now read-only.

Commit

Permalink
feat(toxpk): Add 'ToxPk::getPkSize()' method
Browse files Browse the repository at this point in the history
  • Loading branch information
Diadlo committed Feb 7, 2017
1 parent d351f9e commit f5c0d61
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
13 changes: 11 additions & 2 deletions src/core/toxpk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ QString ToxPk::toString() const

/**
* @brief Returns a pointer to the raw key data.
* @return Pointer to the raw key data, which is exactly TOX_PUBLIC_KEY_SIZE bytes
* long. Returns a nullptr if the ToxPk is empty.
* @return Pointer to the raw key data, which is exactly `ToxPk::getPkSize()`
* bytes long. Returns a nullptr if the ToxPk is empty.
*/
const uint8_t* ToxPk::getBytes() const
{
Expand Down Expand Up @@ -113,3 +113,12 @@ bool ToxPk::isEmpty() const
{
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;
}
1 change: 1 addition & 0 deletions src/core/toxpk.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class ToxPk
const uint8_t* getBytes() const;
bool isEmpty() const;

static int getPkSize();
private:
QByteArray key;
};
Expand Down
2 changes: 1 addition & 1 deletion test/core/toxpk_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ START_TEST(publicKeyTest)
{
ToxPk pk(testPk);
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]);
}
}
Expand Down

0 comments on commit f5c0d61

Please sign in to comment.