2024-10-20 18:21:03 +13:00
|
|
|
#include <QByteArray>
|
|
|
|
#include <QByteArrayView>
|
|
|
|
#include <QCryptographicHash>
|
|
|
|
#include <QIODevice>
|
|
|
|
#include <qcryptographichash.h>
|
|
|
|
#include "gen_qcryptographichash.h"
|
2024-12-11 19:55:47 +13:00
|
|
|
|
2025-01-07 11:30:33 +01:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
} /* extern C */
|
2024-12-11 19:55:47 +13:00
|
|
|
#endif
|
2024-10-20 18:21:03 +13:00
|
|
|
|
2024-12-07 17:15:57 +13:00
|
|
|
QCryptographicHash* QCryptographicHash_new(int method) {
|
|
|
|
return new QCryptographicHash(static_cast<QCryptographicHash::Algorithm>(method));
|
2024-10-20 18:21:03 +13:00
|
|
|
}
|
|
|
|
|
2025-02-01 13:45:16 +13:00
|
|
|
void QCryptographicHash_reset(QCryptographicHash* self) {
|
2024-10-20 18:21:03 +13:00
|
|
|
self->reset();
|
|
|
|
}
|
|
|
|
|
2025-02-01 13:45:16 +13:00
|
|
|
void QCryptographicHash_addData(QCryptographicHash* self, const char* data, ptrdiff_t length) {
|
2024-10-20 18:21:03 +13:00
|
|
|
self->addData(data, (qsizetype)(length));
|
|
|
|
}
|
|
|
|
|
2025-02-01 13:45:16 +13:00
|
|
|
void QCryptographicHash_addDataWithData(QCryptographicHash* self, QByteArrayView* data) {
|
2024-10-20 18:21:03 +13:00
|
|
|
self->addData(*data);
|
|
|
|
}
|
|
|
|
|
2025-02-01 13:45:16 +13:00
|
|
|
bool QCryptographicHash_addDataWithDevice(QCryptographicHash* self, QIODevice* device) {
|
2024-10-20 18:21:03 +13:00
|
|
|
return self->addData(device);
|
|
|
|
}
|
|
|
|
|
2025-02-01 13:45:16 +13:00
|
|
|
struct miqt_string QCryptographicHash_result(const QCryptographicHash* self) {
|
2024-10-20 18:21:03 +13:00
|
|
|
QByteArray _qb = self->result();
|
|
|
|
struct miqt_string _ms;
|
|
|
|
_ms.len = _qb.length();
|
|
|
|
_ms.data = static_cast<char*>(malloc(_ms.len));
|
|
|
|
memcpy(_ms.data, _qb.data(), _ms.len);
|
|
|
|
return _ms;
|
|
|
|
}
|
|
|
|
|
2025-02-01 13:45:16 +13:00
|
|
|
QByteArrayView* QCryptographicHash_resultView(const QCryptographicHash* self) {
|
2024-10-20 18:21:03 +13:00
|
|
|
return new QByteArrayView(self->resultView());
|
|
|
|
}
|
|
|
|
|
2025-02-01 13:45:16 +13:00
|
|
|
struct miqt_string QCryptographicHash_hash(QByteArrayView* data, int method) {
|
2024-10-20 18:21:03 +13:00
|
|
|
QByteArray _qb = QCryptographicHash::hash(*data, static_cast<QCryptographicHash::Algorithm>(method));
|
|
|
|
struct miqt_string _ms;
|
|
|
|
_ms.len = _qb.length();
|
|
|
|
_ms.data = static_cast<char*>(malloc(_ms.len));
|
|
|
|
memcpy(_ms.data, _qb.data(), _ms.len);
|
|
|
|
return _ms;
|
|
|
|
}
|
|
|
|
|
2025-02-01 13:45:16 +13:00
|
|
|
int QCryptographicHash_hashLength(int method) {
|
2024-10-20 18:21:03 +13:00
|
|
|
return QCryptographicHash::hashLength(static_cast<QCryptographicHash::Algorithm>(method));
|
|
|
|
}
|
|
|
|
|
2025-02-01 13:45:16 +13:00
|
|
|
void QCryptographicHash_delete(QCryptographicHash* self) {
|
2025-01-18 17:42:41 +13:00
|
|
|
delete self;
|
2024-10-20 18:21:03 +13:00
|
|
|
}
|
|
|
|
|