//
// Created by Ht on 2022/8/29.
//

#ifndef INC_1_LIBDEVCPP_QGAHONGDOUPLUGINENTRY_H
#define INC_1_LIBDEVCPP_QGAHONGDOUPLUGINENTRY_H

#include "../../src/plugin/QGaCypherPluginEntry.h"
#include "../../src/QGADataPool.h"
#include <mqtt/Base64.h>
#include "hongdouEncrypt.h"

namespace jedge {

//    const char* webKey = "1k8VKDqpOMndSxtDhrExYtTAsV";

    class JE_API  QGaHongdouPluginEntry :
            public QGaCypherPluginEntry {
    protected:
        uint8_t cypherCode[16] = {0xa9,0x31,0x61,0x86,0x9a,0x89,0x2a,0x29,0x01,0x3c,0xcf,0x7e,0x03,0x0d,0x87,0x91};
        uint8_t iv_key[16] = {0x62,0x6f,0x74,0x68,0x61,0x72,0x65,0x65,0x6e,0x67,0x69,0x6e,0x65,0x65,0x72,0x73};

    public:
        explicit QGaHongdouPluginEntry(std::string name, std::string type = "cypher", int ver = 0);

        void buildSiteData(qlibc::QData &data) override;

        QGaCypherPluginEntry *duplication(const string &name) override;

        bool decodeMqttMessage(const string &topic, void *payload, int payloadLen, char *buffer, int *len) override;

        bool encryptMqttMessage(const std::string& payload, std::string& encryptOut) override;
    };
}


#endif //INC_1_LIBDEVCPP_QGAWANJAPLUGINENTRY_H
