9#include <QCryptographicHash>
14QByteArray AccessToken::generate(
const QByteArray &entropy) {
16 QByteArray result = QCryptographicHash::hash(entropy, QCryptographicHash::Sha256);
18 srand(
static_cast<unsigned int>(time(
nullptr)));
19 for (
int i = 0; i < 256; ++i) {
20 char byte =
static_cast<char>(rand() % 256);
21 result.push_back(
byte);
24 return QCryptographicHash::hash(result, QCryptographicHash::Sha256);
28 _duration =
static_cast<int>(QDateTime::currentSecsSinceEpoch()) + duration;
29 _data = generate(entropy);
41 return (_duration > QDateTime::currentSecsSinceEpoch()) &&
52 return _data == other._data;
The AccessToken class contains information duration of the access. Token are byte array for validatio...
QDataStream & toStream(QDataStream &stream) const
fromStream This method should be write all members of the current object to the stream object.
QDataStream & fromStream(QDataStream &stream)
fromStream This method should be read all bytes from the stream object and full the current object.
bool operator==(const AccessToken &other) const
operator == compare left and right values with type AccessToken.
bool operator!=(const AccessToken &other) const
operator != compare left and right values with type AccessToken.
AccessToken & operator=(const AccessToken &other)
operator = this is operator of copy objects.
bool isValid() const
isValid This method check this toke to valid.
void clear()
clearThis Method reset all data of token.
AccessToken()
AccessToken constructor by default create not valid token.
bool fromBytes(const QByteArray &data)
fromBytes This method provide initialization of object from byte array.
The QH namespace - QuasarApp Heart namespace. This namespace contains all classes of the Heart librar...