//
// Created by #Suyghur, on 2021/06/11.
//

#ifndef EYUANGAMESDK_KTX_AES_UTILS_H
#define EYUANGAMESDK_KTX_AES_UTILS_H

#include "aes.h"

#define BLOCKLEN 16

#ifdef __cplusplus
extern "C" {
#endif

class AesUtils {
public:
    static uint8_t *GetKey();

    static char *GetRawKey();


    static uint8_t *GetIv(const uint8_t *key);

    static char *GetIv32(const char *key);


    /** AES加密, CBC, PKCS5Padding */
    static char *Encrypt(const char *input, const uint8_t *key);

    /** AES解密, CBC, PKCS5Padding */
    static char *Decrypt(const char *input, const uint8_t *key);

    static std::string Encrypt2(JNIEnv *env, const std::string &key, const std::string &raw);

    static std::string Decrypt2(JNIEnv *env, const std::string &key, const std::string &enc);


private:
    static uint8_t *GetPaddingInput(const char *input);

    static int FindPaddingIndex(uint8_t *str, size_t length);

    static void RemovePadding(uint8_t *out, size_t length);
};


#ifdef __cplusplus
}
#endif


#endif //EYUANGAMESDK_KTX_AES_UTILS_H
