Class sh::tools::Misc

class sh::tools::Misc

Public Static Functions

QByteArray iconToPngByteArray(QIcon icon, int sizeInPt)

Computes a png representation for an icon.

QByteArray iconToBase64SrcEncoding(QIcon icon, int sizeInPt)

Computes a html-compatible ‘data:image/png;base64,…’ png representation for an icon.

QByteArray hash(QStringList data)

Hashes string data in a cryptographical way (with a salt).

Use with compareHash().

QByteArray hashUnsalted(QStringList data)

Hashes string data in a cryptographical way without a salt.

Use with compareHash() or just compare strings.

bool compareHash(QByteArray hash, QStringList data)

Check if a hash is matching to given string data.

QByteArray qjsonToJson(QJsonObject o)

Returns a json string for a QJsonObject, QJsonValue or QJsonArray.

QByteArray qjsonToJson(QJsonValue o)
QByteArray qjsonToJson(QJsonArray a)
QByteArray qmapToJson(QVariantMap m)

Returns a json string for a QVariantMap.

QByteArray jsonableToJson(Jsonable *a)

Returns a json string from a Jsonable.

QByteArray randomBytes(int length = 32)

Returns a random byte array.

QByteArray generateUniqueHash()

Returns a (mostly) random generated unique hash.

void makeHttpRequest(QUrl url, QByteArray *responseBody = nullptr, QString *mimeType = nullptr, int *httpStatus = nullptr)

Makes an http request (as a client).

httpStatus can return 0 for network errors and similar.

Private Functions

Misc()

Private Static Functions

QByteArray _hash(QStringList data, bool salted, QByteArray _withSalt)

Private Static Attributes

QByteArray _jundefined
QNetworkAccessManager _qnetwork