//
// Created by #Suyghur, on 2021/10/15.
//

#ifndef XINRUIGAMESDK_AES_KIT_H
#define XINRUIGAMESDK_AES_KIT_H

#include <cstdint>

#define BLOCK_LEN 16

#define AES_KEY "8eb99e1f9813f24b5edb7a501ceae5ac"

#define IV "8eb99e1f9813f24b"

#ifdef __cplusplus
extern "C" {
#endif

class AesKit {
public:

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

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

    static jstring Encrypt(JNIEnv *env, const char *input);

    static jstring Decrypt(JNIEnv *env, const char *input);

private:

    static uint8_t *GetPaddingInput(const char *input);

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

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

};

#ifdef __cplusplus
}
#endif


#endif //XINRUIGAMESDK_AES_KIT_H
