QXmppBitsOfBinaryContentId Class
| Header: | #include <QXmppBitsOfBinaryContentId> |
| Since: | QXmpp 1.2 |
Public Functions
| QXmppBitsOfBinaryContentId() | |
| QXmppBitsOfBinaryContentId(const QXmppBitsOfBinaryContentId &cid) | |
| QXmppBitsOfBinaryContentId(QXmppBitsOfBinaryContentId &&cid) | |
| ~QXmppBitsOfBinaryContentId() | |
| QCryptographicHash::Algorithm | algorithm() const |
| QByteArray | hash() const |
| bool | isValid() const |
| void | setAlgorithm(QCryptographicHash::Algorithm algo) |
| void | setHash(const QByteArray &hash) |
| QString | toCidUrl() const |
| QString | toContentId() const |
| QXmppBitsOfBinaryContentId & | operator=(QXmppBitsOfBinaryContentId &&other) |
| QXmppBitsOfBinaryContentId & | operator=(const QXmppBitsOfBinaryContentId &other) |
| bool | operator==(const QXmppBitsOfBinaryContentId &other) const |
Static Public Members
| QXmppBitsOfBinaryContentId | fromCidUrl(const QString &input) |
| QXmppBitsOfBinaryContentId | fromContentId(const QString &input) |
| bool | isBitsOfBinaryContentId(const QString &input, bool checkIsCidUrl = false) |
Detailed Description
QXmppBitsOfBinaryContentId represents a link to or an identifier of XEP-0231: Bits of Binary data.
Currently supported hash algorithms:
- MD4
- MD5
- SHA-1
- SHA-2 (SHA-224, SHA-256, SHA-384, SHA-512)
- SHA-3 (SHA3-224, SHA3-256, SHA3-384, SHA3-512)
- BLAKE2 (BLAKE2b256, BLAKE2b512) (requires Qt 6, since QXmpp 1.5)
Note: Security notice: When using the content IDs to cache data between multiple entities it is important to avoid hash collisions. SHA-1 cannot fulfill this requirement. You SHOULD use another more secure hash algorithm if you do this.
input.
Member Function Documentation
QXmppBitsOfBinaryContentId::QXmppBitsOfBinaryContentId()
Default contructor
QXmppBitsOfBinaryContentId::QXmppBitsOfBinaryContentId(const QXmppBitsOfBinaryContentId &cid)
Default copy-constructor
QXmppBitsOfBinaryContentId::QXmppBitsOfBinaryContentId(QXmppBitsOfBinaryContentId &&cid)
Default move-constructor
[noexcept] QXmppBitsOfBinaryContentId::~QXmppBitsOfBinaryContentId()
Default destructor
QCryptographicHash::Algorithm QXmppBitsOfBinaryContentId::algorithm() const
Returns the hash algorithm used to calculate the hash value
The default value is QCryptographicHash::Sha1.
See also setAlgorithm().
[static] QXmppBitsOfBinaryContentId QXmppBitsOfBinaryContentId::fromCidUrl(const QString &input)
Parses a QXmppBitsOfBinaryContentId from a XEP-0231: Bits of Binary cid: URL
In case parsing failed, the returned QXmppBitsOfBinaryContentId is empty.
input.
See also QXmppBitsOfBinaryContentId::fromContentId.
[static] QXmppBitsOfBinaryContentId QXmppBitsOfBinaryContentId::fromContentId(const QString &input)
Parses a QXmppBitsOfBinaryContentId from a XEP-0231: Bits of Binary content id
In case parsing failed, the returned QXmppBitsOfBinaryContentId is empty.
Note: This does not allow cid: URLs to be passed. Use QXmppBitsOfBinaryContentId::fromCidUrl for that purpose.
input.
See also QXmppBitsOfBinaryContentId::fromCidUrl.
QByteArray QXmppBitsOfBinaryContentId::hash() const
Returns the hash value in binary form
See also setHash().
[static] bool QXmppBitsOfBinaryContentId::isBitsOfBinaryContentId(const QString &input, bool checkIsCidUrl = false)
Checks whether input is a Bits of Binary content id or cid: URL.
input is the string to be checked. If checkIsCidUrl is true, only cid: URLs are accepted.
Returns true, if input is valid.
bool QXmppBitsOfBinaryContentId::isValid() const
Returns true if the content id is valid and can be serialized into a string.
Also checks the length of the hash.
Returns true, if the set hashing algorithm is supported, a hash value is set and its length is correct, false otherwise.
void QXmppBitsOfBinaryContentId::setAlgorithm(QCryptographicHash::Algorithm algo)
Sets the hash algorithm used to calculate the hash value
The default value is QCryptographicHash::Sha1.
Note: Only change this, if you know what you do. The XEP allows other hashing algorithms than SHA-1 to be used, but not all clients support this.
algo.
See also algorithm().
void QXmppBitsOfBinaryContentId::setHash(const QByteArray &hash)
Sets the hash value in binary form
See also hash().
QString QXmppBitsOfBinaryContentId::toCidUrl() const
Returns a XEP-0231: Bits of Binary cid: URL
QString QXmppBitsOfBinaryContentId::toContentId() const
Returns a XEP-0231: Bits of Binary content id
QXmppBitsOfBinaryContentId &QXmppBitsOfBinaryContentId::operator=(QXmppBitsOfBinaryContentId &&other)
Default move-assignment operator, moving from other.
QXmppBitsOfBinaryContentId &QXmppBitsOfBinaryContentId::operator=(const QXmppBitsOfBinaryContentId &other)
Default assignment operator, copying other.
bool QXmppBitsOfBinaryContentId::operator==(const QXmppBitsOfBinaryContentId &other) const
Returns true if this content ID and other are equal.