2024-08-25 04:08:24 +00:00
|
|
|
#include <QByteArray>
|
|
|
|
#include <QCryptographicHash>
|
|
|
|
#include <QIODevice>
|
2024-08-29 07:01:51 +00:00
|
|
|
#include "qcryptographichash.h"
|
2024-08-25 04:08:24 +00:00
|
|
|
|
2024-08-29 07:01:51 +00:00
|
|
|
#include "gen_qcryptographichash.h"
|
2024-08-25 04:08:24 +00:00
|
|
|
|
|
|
|
extern "C" {
|
|
|
|
extern void miqt_exec_callback(void* cb, int argc, void* argv);
|
|
|
|
}
|
|
|
|
|
2024-08-29 07:01:51 +00:00
|
|
|
QCryptographicHash* QCryptographicHash_new(uintptr_t method) {
|
|
|
|
return new QCryptographicHash(static_cast<QCryptographicHash::Algorithm>(method));
|
|
|
|
}
|
|
|
|
|
2024-08-25 04:08:24 +00:00
|
|
|
void QCryptographicHash_Reset(QCryptographicHash* self) {
|
|
|
|
self->reset();
|
|
|
|
}
|
|
|
|
|
2024-08-29 07:01:51 +00:00
|
|
|
void QCryptographicHash_AddData(QCryptographicHash* self, const char* data, int length) {
|
2024-08-25 04:08:24 +00:00
|
|
|
self->addData(data, static_cast<int>(length));
|
|
|
|
}
|
|
|
|
|
|
|
|
void QCryptographicHash_AddDataWithData(QCryptographicHash* self, QByteArray* data) {
|
|
|
|
self->addData(*data);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool QCryptographicHash_AddDataWithDevice(QCryptographicHash* self, QIODevice* device) {
|
|
|
|
return self->addData(device);
|
|
|
|
}
|
|
|
|
|
|
|
|
QByteArray* QCryptographicHash_Result(QCryptographicHash* self) {
|
2024-08-29 07:01:51 +00:00
|
|
|
QByteArray ret = const_cast<const QCryptographicHash*>(self)->result();
|
2024-08-25 04:08:24 +00:00
|
|
|
// Copy-construct value returned type into heap-allocated copy
|
|
|
|
return static_cast<QByteArray*>(new QByteArray(ret));
|
|
|
|
}
|
|
|
|
|
2024-08-29 07:01:51 +00:00
|
|
|
QByteArray* QCryptographicHash_Hash(QByteArray* data, uintptr_t method) {
|
|
|
|
QByteArray ret = QCryptographicHash::hash(*data, static_cast<QCryptographicHash::Algorithm>(method));
|
|
|
|
// Copy-construct value returned type into heap-allocated copy
|
|
|
|
return static_cast<QByteArray*>(new QByteArray(ret));
|
|
|
|
}
|
|
|
|
|
|
|
|
int QCryptographicHash_HashLength(uintptr_t method) {
|
|
|
|
return QCryptographicHash::hashLength(static_cast<QCryptographicHash::Algorithm>(method));
|
|
|
|
}
|
|
|
|
|
2024-08-25 04:08:24 +00:00
|
|
|
void QCryptographicHash_Delete(QCryptographicHash* self) {
|
|
|
|
delete self;
|
|
|
|
}
|
|
|
|
|