AiDataTaskRuner/UI/TabUtil/Encrypter.mqh
Nique_372 b2142ea9b4
2026-03-29 11:06:50 -05:00

499 lines
22 KiB
MQL5

//+------------------------------------------------------------------+
//| Encrypter.mqh |
//| Copyright 2026, Niquel Mendoza. |
//| https://www.mql5.com/es/users/nique_372 |
//+------------------------------------------------------------------+
#property copyright "Copyright 2026, Niquel Mendoza."
#property link "https://www.mql5.com/es/users/nique_372"
#property strict
#ifndef AIDATATASKRUNER_UI_TABUTIL_ENCRYPTER_MQH
#define AIDATATASKRUNER_UI_TABUTIL_ENCRYPTER_MQH
//+------------------------------------------------------------------+
//| Include |
//+------------------------------------------------------------------+
//---
#include "Clean.mqh"
//--- Generador de aleatorios de alta calidad
#include "..\\..\\..\\Xoshiro256\\Xoshiro256.mqh"
//--- For keys (para keys)
#include <TSN\\EAFMod\\Keys.mqh>
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
/*
2026.03.26 17:37:44.570 Test (EURUSD,H1) CRYPT_BASE64 = 0
2026.03.26 17:37:44.570 Test (EURUSD,H1) CRYPT_AES128 = 1
2026.03.26 17:37:44.570 Test (EURUSD,H1) CRYPT_AES256 = 2
2026.03.26 17:37:44.570 Test (EURUSD,H1) CRYPT_DES = 3
2026.03.26 17:37:44.570 Test (EURUSD,H1) CRYPT_HASH_SHA1 = 4
2026.03.26 17:37:44.570 Test (EURUSD,H1) CRYPT_HASH_SHA256 = 5
2026.03.26 17:37:44.570 Test (EURUSD,H1) CRYPT_HASH_MD5 = 6
2026.03.26 17:37:44.570 Test (EURUSD,H1) CRYPT_ARCH_ZIP = 7
*/
//---
string g_tabuils_arr_type_encrypt[3]
{
"AES 128 (Key 16 chars)", // 0
"AES 256 (Key 32 chars)", // 1
"DES (Key 7 chars)" // 2
};
//---
uchar Xoshiro256GenerateRandomUchar(void* ptr, uchar start, uchar stop) { return (uchar)((Xoshiro256*)ptr).RandomInteger(start, stop); }
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
class CTabUtilsEncryther : public CGuiBaseComponent<CLoggerBase>
{
private:
//---
CTabUtilsGeneral* m_general;
//--- General
Xoshiro256 m_random; // Generador de keys
CFolderOpsEncrypt m_folder_encryptor;
//--- Fronted
//- Encriptacion
CTextLabel m_label_tit_enc;
// Tipo de encryptacion
CComboBox m_combox_encrypt_type;
//---
CSeparateLine m_sep_start_config_enc;
// Arhicvo de configuracion
// Tambien se ubican las exntension a limpiar y archivos que se deberan de explcuir
CTextLabel m_label_file_config_encrypt;
CTextLabel m_label_file_config_encrypt_val;
CButton m_btn_browse_file_config_encrypt;
CButton m_btn_browse_file_config_encrypt_template; // Boton para selecionar el archivo template
// Prefijo para el archivo encryptado
CTextEdit m_edit_encrypt_prefix;
// Edit de encryptacion (key)
CTextEdit m_edit_encrypt_key;
CButton m_btn_encrypt_key_show_hide; // Ver o ocultar dicha clave
CButton m_btn_encrypt_aleatorie_key; // Key aleatoria
// Ejecutar la limpieza
CButton m_btn_encrypt_run;
//---
void OnRunEncrypt();
public:
CTabUtilsEncryther(void);
~CTabUtilsEncryther(void) {}
//---
void SetGeneral(CTabUtilsGeneral* general) { m_general = general; }
//---
bool Create(CWndCreate* p, CWindow& main_window, int top_gap, int left_gap, int right_gap, int bottom_gap);
//---
bool OnClickButtom(const long lparam);
void OnLenguajeChange() override final;
};
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
CTabUtilsEncryther::CTabUtilsEncryther(void)
: CGuiBaseComponent<CLoggerBase>("CTabUtilsEncryther")
{
m_folder_encryptor.AddLogFlags(LOG_ALL);
m_folder_encryptor.Encryptor(&g_mqlarticles_encryptor);
m_folder_encryptor.RandomForEncryptor(&m_random); // por siacaso
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
bool CTabUtilsEncryther::Create(CWndCreate* p, CWindow& main_window, int top_gap, int left_gap, int right_gap, int bottom_gap)
{
//---
int x = left_gap + 5;
int y = top_gap + 10;
const int inital_x = x;
//--- Titulo Encrypt
m_label_tit_enc.FontSize(14);
m_label_tit_enc.Font("Arial");
m_label_tit_enc.LabelColor(AIDATATASKRUNER_COLOR_TEXT_PRIMARY);
m_label_tit_enc.BackColor(AIDATATASKRUNER_COLOR_FONDO_SUBTAB_PRESSED);
if(!p.CreateTextLabel(m_label_tit_enc, m_language[GUIBASE_COMPONENT_NAME(m_label_tit_enc)],
main_window, 0, m_base_tab, m_base_tab_idx, x, y, 200))
{
GUIBASE_ERROR_CREATION(m_label_tit_enc);
return false;
}
y += m_label_tit_enc.YSize() + 10;
//--- ComboBox tipo de encryptacion
m_combox_encrypt_type.FontSize(10);
m_combox_encrypt_type.LabelColor(AIDATATASKRUNER_COLOR_TEXT_SECONDARY);
m_combox_encrypt_type.BackColor(AIDATATASKRUNER_COLOR_FONDO_SUBTAB_PRESSED);
m_combox_encrypt_type.GetListViewPointer().BackColor(AIDATATASKRUNER_COLOR_EDIT_BACK);
m_combox_encrypt_type.GetListViewPointer().BorderColor(AIDATATASKRUNER_COLOR_EDIT_BORDER);
m_combox_encrypt_type.GetListViewPointer().LabelColor(AIDATATASKRUNER_COLOR_TEXT_SECONDARY);
m_combox_encrypt_type.GetButtonPointer().LabelColor(AIDATATASKRUNER_COLOR_TEXT_SECONDARY);
m_combox_encrypt_type.GetButtonPointer().BackColor(AIDATATASKRUNER_COLOR_EDIT_BACK);
m_combox_encrypt_type.GetButtonPointer().BorderColor(AIDATATASKRUNER_COLOR_EDIT_BORDER);
m_combox_encrypt_type.Tooltip(m_language.Tooltip(GUIBASE_COMPONENT_NAME(m_combox_encrypt_type)));
if(!p.CreateCombobox(m_combox_encrypt_type, m_language[GUIBASE_COMPONENT_NAME(m_combox_encrypt_type)],
main_window, 0, m_base_tab, m_base_tab_idx, false, x, y, 50 + 10 + 130, 130,
g_tabuils_arr_type_encrypt, 150))
{
GUIBASE_ERROR_CREATION(m_combox_encrypt_type);
return false;
}
m_combox_encrypt_type.m_button.IconFile(RESOURCE_DOWN_THIN_WHITE);
m_combox_encrypt_type.m_button.IconFileLocked(RESOURCE_DOWN_THIN_WHITE);
m_combox_encrypt_type.m_button.CElement::IconFilePressed(RESOURCE_UP_THIN_WHITE);
m_combox_encrypt_type.m_button.CElement::IconFilePressedLocked(RESOURCE_UP_THIN_WHITE);
y += m_combox_encrypt_type.YSize() + 6;
//---
m_base_tab.AddToElementsArray(m_base_tab_idx, m_sep_start_config_enc);
const int xsize = main_window.X2() - inital_x - inital_x;
if(!p.CreateSepLine(m_sep_start_config_enc, main_window, 0, inital_x, y, xsize, (9 + 25 + 25 + 8 + 7), AIDATATASKRUNER_COLOR_BTN_BORDER, AIDATATASKRUNER_COLOR_BTN_BORDER, H_SEP_LINE))
{
GUIBASE_ERROR_CREATION(m_sep_start_config_enc);
return false;
}
y += 2 + 7;
//--- Label config encrypt
m_label_file_config_encrypt.FontSize(10);
m_label_file_config_encrypt.Font("Arial");
m_label_file_config_encrypt.LabelColor(AIDATATASKRUNER_COLOR_TEXT_SECONDARY);
m_label_file_config_encrypt.BackColor(AIDATATASKRUNER_COLOR_FONDO_SUBTAB_PRESSED);
if(!p.CreateTextLabel(m_label_file_config_encrypt, m_language[GUIBASE_COMPONENT_NAME(m_label_file_config_encrypt)],
main_window, 0, m_base_tab, m_base_tab_idx, x, y, 125, 25))
{
GUIBASE_ERROR_CREATION(m_label_file_config_encrypt);
return false;
}
x += m_label_file_config_encrypt.XSize() + 5;
//--- Label val
m_label_file_config_encrypt_val.FontSize(10);
m_label_file_config_encrypt_val.Font("Arial");
m_label_file_config_encrypt_val.LabelColor(AIDATATASKRUNER_COLOR_TEXT_PRIMARY);
m_label_file_config_encrypt_val.BackColor(AIDATATASKRUNER_COLOR_EDIT_BACK);
m_label_file_config_encrypt_val.LabelXGap(5);
m_label_file_config_encrypt_val.LabelYGap(3);
m_label_file_config_encrypt_val.Tooltip(m_language.Tooltip(GUIBASE_COMPONENT_NAME(m_label_file_config_encrypt_val)));
if(!p.CreateTextLabel(m_label_file_config_encrypt_val, "",
main_window, 0, m_base_tab, m_base_tab_idx, x, y, 400, 25))
{
GUIBASE_ERROR_CREATION(m_label_file_config_encrypt_val);
return false;
}
x = inital_x;
y += m_label_file_config_encrypt_val.YSize() + 8;
//--- Browse
m_btn_browse_file_config_encrypt.AddImagesGroup(5, 2, g_eafmod_ic_arr_folderw10_image);
m_btn_browse_file_config_encrypt.ChangeImage(0, 0);
m_btn_browse_file_config_encrypt.LabelXGap(22);
m_btn_browse_file_config_encrypt.FontSize(10);
m_btn_browse_file_config_encrypt.Font("Arial");
m_btn_browse_file_config_encrypt.BackColor(AIDATATASKRUNER_COLOR_BTN_BACK);
m_btn_browse_file_config_encrypt.LabelColor(AIDATATASKRUNER_COLOR_TEXT_SECONDARY);
m_btn_browse_file_config_encrypt.BorderColor(AIDATATASKRUNER_COLOR_BTN_BORDER);
m_btn_browse_file_config_encrypt.Tooltip(m_language.Tooltip(GUIBASE_COMPONENT_NAME(m_btn_browse_file_config_encrypt)));
if(!p.CreateButton(m_btn_browse_file_config_encrypt, m_language[GUIBASE_COMPONENT_NAME(m_btn_browse_file_config_encrypt)],
main_window, 0, m_base_tab, m_base_tab_idx, x, y, 100))
{
GUIBASE_ERROR_CREATION(m_btn_browse_file_config_encrypt);
return false;
}
x += m_btn_browse_file_config_encrypt.XSize() + 5;
//--- Template "?"
m_btn_browse_file_config_encrypt_template.AddImagesGroup(5, 2, g_eafmod_ic_arr_help_image);
m_btn_browse_file_config_encrypt_template.ChangeImage(0, 0);
m_btn_browse_file_config_encrypt_template.FontSize(10);
m_btn_browse_file_config_encrypt_template.Font("Arial");
m_btn_browse_file_config_encrypt_template.BackColor(AIDATATASKRUNER_COLOR_FONDO_SUBTAB_PRESSED);
m_btn_browse_file_config_encrypt_template.LabelColor(AIDATATASKRUNER_COLOR_TEXT_SECONDARY);
m_btn_browse_file_config_encrypt_template.BorderColor(AIDATATASKRUNER_COLOR_FONDO_SUBTAB_PRESSED);
m_btn_browse_file_config_encrypt_template.Tooltip(m_language.Tooltip(GUIBASE_COMPONENT_NAME(m_btn_browse_file_config_encrypt_template)));
if(!p.CreateButton(m_btn_browse_file_config_encrypt_template, "",
main_window, 0, m_base_tab, m_base_tab_idx, x, y, 30))
{
GUIBASE_ERROR_CREATION(m_btn_browse_file_config_encrypt_template);
return false;
}
x = inital_x;
y += m_btn_browse_file_config_encrypt_template.YSize() + 18;
//--- Edit prefix
string texto = m_language[GUIBASE_COMPONENT_NAME(m_edit_encrypt_prefix)];
m_edit_encrypt_prefix.FontSize(10);
m_edit_encrypt_prefix.Font("Arial");
m_edit_encrypt_prefix.CanvasFontSet();
int width = m_edit_encrypt_prefix.m_canvas.TextWidth(texto);
m_edit_encrypt_prefix.LabelColor(AIDATATASKRUNER_COLOR_TEXT_SECONDARY);
m_edit_encrypt_prefix.BackColor(AIDATATASKRUNER_COLOR_FONDO_SUBTAB_PRESSED);
m_edit_encrypt_prefix.GetTextBoxPointer().BackColor(AIDATATASKRUNER_COLOR_EDIT_BACK);
m_edit_encrypt_prefix.GetTextBoxPointer().BorderColor(AIDATATASKRUNER_COLOR_EDIT_BORDER);
m_edit_encrypt_prefix.GetTextBoxPointer().DefaultTextColor(AIDATATASKRUNER_COLOR_EDIT_TEXT_NORMAL);
m_edit_encrypt_prefix.GetTextBoxPointer().LabelColor(AIDATATASKRUNER_COLOR_EDIT_TEXT_NORMAL);
m_edit_encrypt_prefix.GetTextBoxPointer().SelectedBackColor(AIDATATASKRUNER_COLOR_EDIT_TEXT_SELECTED);
m_edit_encrypt_prefix.GetTextBoxPointer().SelectedTextColor(AIDATATASKRUNER_COLOR_EDIT_TEXT_HIGHLIGHT);
m_edit_encrypt_prefix.Tooltip(m_language.Tooltip(GUIBASE_COMPONENT_NAME(m_edit_encrypt_prefix)));
if(!p.CreateTextEdit(m_edit_encrypt_prefix, texto,
main_window, 0, m_base_tab, m_base_tab_idx, false, x, y,
width + 10 + 150, 150, ".enc"))
{
GUIBASE_ERROR_CREATION(m_edit_encrypt_prefix);
return false;
}
y += m_edit_encrypt_prefix.YSize() + 10;
//--- Edit key
texto = m_language[GUIBASE_COMPONENT_NAME(m_edit_encrypt_key)];
m_edit_encrypt_key.FontSize(10);
m_edit_encrypt_key.Font("Arial");
m_edit_encrypt_key.CanvasFontSet();
width = m_edit_encrypt_key.m_canvas.TextWidth(texto);
m_edit_encrypt_key.LabelColor(AIDATATASKRUNER_COLOR_TEXT_SECONDARY);
m_edit_encrypt_key.BackColor(AIDATATASKRUNER_COLOR_FONDO_SUBTAB_PRESSED);
m_edit_encrypt_key.GetTextBoxPointer().BackColor(AIDATATASKRUNER_COLOR_EDIT_BACK);
m_edit_encrypt_key.GetTextBoxPointer().BorderColor(AIDATATASKRUNER_COLOR_EDIT_BORDER);
m_edit_encrypt_key.GetTextBoxPointer().DefaultTextColor(AIDATATASKRUNER_COLOR_EDIT_TEXT_NORMAL);
m_edit_encrypt_key.GetTextBoxPointer().LabelColor(AIDATATASKRUNER_COLOR_EDIT_TEXT_NORMAL);
m_edit_encrypt_key.GetTextBoxPointer().SelectedBackColor(AIDATATASKRUNER_COLOR_EDIT_TEXT_SELECTED);
m_edit_encrypt_key.GetTextBoxPointer().SelectedTextColor(AIDATATASKRUNER_COLOR_EDIT_TEXT_HIGHLIGHT);
m_edit_encrypt_key.Tooltip(m_language.Tooltip(GUIBASE_COMPONENT_NAME(m_edit_encrypt_key)));
if(!p.CreateTextEdit(m_edit_encrypt_key, texto,
main_window, 0, m_base_tab, m_base_tab_idx, false, x, y,
width + 10 + 250, 250, ""))
{
GUIBASE_ERROR_CREATION(m_edit_encrypt_key);
return false;
}
m_edit_encrypt_key.GetTextBoxPointer().Font(EAFMOD_KEY_FONT);
//--- Btn aleatorio "↺" (va primero)
const int edit_key_y = m_edit_encrypt_key.YSize();
m_btn_encrypt_aleatorie_key.FontSize(10);
m_btn_encrypt_aleatorie_key.LabelColor(AIDATATASKRUNER_COLOR_TEXT_SECONDARY);
m_btn_encrypt_aleatorie_key.BackColor(AIDATATASKRUNER_COLOR_BTN_BACK);
m_btn_encrypt_aleatorie_key.BorderColor(AIDATATASKRUNER_COLOR_BTN_BORDER);
m_btn_encrypt_aleatorie_key.Tooltip(m_language.Tooltip(GUIBASE_COMPONENT_NAME(m_btn_encrypt_aleatorie_key)));
if(!p.CreateButton(m_btn_encrypt_aleatorie_key, "",
main_window, 0, m_base_tab, m_base_tab_idx,
x + m_edit_encrypt_key.XSize() + 5, y, edit_key_y))
{
GUIBASE_ERROR_CREATION(m_btn_encrypt_aleatorie_key);
return false;
}
//--- Btn show/hide (va despues del aleatorio, con imagen)
m_btn_encrypt_key_show_hide.AddImagesGroup(1, 1, g_llmagetn_tab_images_vis_path);
m_btn_encrypt_key_show_hide.ChangeImage(0, EAFMOD_FORKEYS_IMAGES_VIS_CLOSED);
m_btn_encrypt_key_show_hide.XSize(edit_key_y);
m_btn_encrypt_key_show_hide.YSize(edit_key_y);
m_btn_encrypt_key_show_hide.LabelColor(AIDATATASKRUNER_COLOR_TEXT_SECONDARY);
m_btn_encrypt_key_show_hide.BackColor(AIDATATASKRUNER_COLOR_BTN_BACK);
m_btn_encrypt_key_show_hide.BorderColor(AIDATATASKRUNER_COLOR_BTN_BORDER);
m_btn_encrypt_key_show_hide.Tooltip(m_language.Tooltip(GUIBASE_COMPONENT_NAME(m_btn_encrypt_key_show_hide)));
if(!p.CreateButton(m_btn_encrypt_key_show_hide, "",
main_window, 0, m_base_tab, m_base_tab_idx,
x + m_edit_encrypt_key.XSize() + 5 + edit_key_y + 5, y, edit_key_y))
{
GUIBASE_ERROR_CREATION(m_btn_encrypt_key_show_hide);
return false;
}
x = inital_x;
y += edit_key_y + 10;
//--- Btn Run
m_btn_encrypt_run.FontSize(10);
m_btn_encrypt_run.Font("Arial");
m_btn_encrypt_run.BackColor(AIDATATASKRUNER_COLOR_BTN_BACK);
m_btn_encrypt_run.LabelColor(AIDATATASKRUNER_COLOR_TEXT_SECONDARY);
m_btn_encrypt_run.BorderColor(AIDATATASKRUNER_COLOR_BTN_BORDER);
m_btn_encrypt_run.Tooltip(m_language.Tooltip(GUIBASE_COMPONENT_NAME(m_btn_encrypt_run)));
if(!p.CreateButton(m_btn_encrypt_run, m_language[GUIBASE_COMPONENT_NAME(m_btn_encrypt_run)],
main_window, 0, m_base_tab, m_base_tab_idx, x, y, 120))
{
GUIBASE_ERROR_CREATION(m_btn_encrypt_run);
return false;
}
x = inital_x;
y += m_btn_encrypt_run.YSize() + 20;
//---
return true;
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void CTabUtilsEncryther::OnLenguajeChange(void)
{
//---
UpdateTBasic(m_label_tit_enc, GUIBASE_COMPONENT_NAME(m_label_tit_enc), false);
ResizeTElement(m_combox_encrypt_type, GUIBASE_COMPONENT_NAME(m_combox_encrypt_type), 130, 10);
//---
// Label
UpdateTBasic(m_label_file_config_encrypt, GUIBASE_COMPONENT_NAME(m_label_file_config_encrypt), false);
// Val
m_label_file_config_encrypt_val.Tooltip(m_language.Tooltip(GUIBASE_COMPONENT_NAME(m_label_file_config_encrypt_val)));
// Browse
UpdateTBasic(m_btn_browse_file_config_encrypt, GUIBASE_COMPONENT_NAME(m_btn_browse_file_config_encrypt), true);
// Temaplte
m_btn_browse_file_config_encrypt_template.Tooltip(m_language.Tooltip(GUIBASE_COMPONENT_NAME(m_btn_browse_file_config_encrypt_template)));
//--- Prefix
ResizeTElement(m_edit_encrypt_prefix, GUIBASE_COMPONENT_NAME(m_edit_encrypt_prefix), 150, 10);
//---
// Key
ResizeTElement(m_edit_encrypt_key, GUIBASE_COMPONENT_NAME(m_edit_encrypt_key), 250, 10);
// Aleatorio
m_btn_encrypt_aleatorie_key.Tooltip(m_language.Tooltip(GUIBASE_COMPONENT_NAME(m_btn_encrypt_aleatorie_key)));
// ShowHide
m_btn_encrypt_key_show_hide.Tooltip(m_language.Tooltip(GUIBASE_COMPONENT_NAME(m_btn_encrypt_key_show_hide)));
//--- Run
UpdateTBasic(m_btn_encrypt_run, GUIBASE_COMPONENT_NAME(m_btn_encrypt_run), false);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
bool CTabUtilsEncryther::OnClickButtom(const long lparam)
{
//--- Encrypt
// Valor (browse)
if(m_btn_browse_file_config_encrypt.Id() == lparam)
{
//---
string arr[];
if(FileSelectDialog(GUIBASE_MSG("flselect_config_encrypt"), NULL, "JSON Files (*.json)|*.json", (m_general.ComonFlagVal() ? FSD_COMMON_FOLDER : 0),
arr, NULL) != 1)
{
MessageBox(GUIBASE_MSG("error_select_file"), GUIBASE_COMMON("error"), MB_ICONERROR | MB_OK);
return true;
}
//---
m_label_file_config_encrypt_val.LabelText(arr[0]); // ruta completa aqui
m_label_file_config_encrypt_val.Update(true);
//---
if(!m_folder_encryptor.Load(arr[0], m_general.ComonFlagVal(), g_json_parser))
{
MessageBox(GUIBASE_MSG("error_loadjson_enc"), GUIBASE_COMMON("error"), MB_ICONERROR | MB_OK);
}
return true;
}
// Template
if(m_btn_browse_file_config_encrypt_template.Id() == lparam)
{
//---
string arr[];
if(FileSelectDialog(GUIBASE_MSG("flselect_config_encrypt"), AIDATATASKRUNER_PATH_TEMPLATES, "JSON Files (*.json)|*.json", AIDATATASK_RUNNER_FSD_COMON_FLAG,
arr, AIDATATASKRUNER_FILENAME_TEMPLATES_FILEINCLUEXCLU_ENC) != 1)
{
MessageBox(GUIBASE_MSG("error_select_file"), GUIBASE_COMMON("error"), MB_ICONERROR | MB_OK);
return true;
}
//---
m_label_file_config_encrypt_val.LabelText(arr[0]); // ruta completa aqui
m_label_file_config_encrypt_val.Update(true);
//---
if(!m_folder_encryptor.Load(arr[0], AIDATATASK_RUNNER_COMON_FLAG_VAL, g_json_parser))
{
MessageBox(GUIBASE_MSG("error_loadjson_enc"), GUIBASE_COMMON("error"), MB_ICONERROR | MB_OK);
}
return true;
}
// Run
if(m_btn_encrypt_run.Id() == lparam)
{
m_btn_encrypt_run.LabelText(m_language[GUIBASE_COMPONENT_NAME(m_btn_encrypt_run) + "_onrun"]);
m_btn_encrypt_run.Update(true);
OnRunEncrypt();
m_btn_encrypt_run.LabelText(m_language[GUIBASE_COMPONENT_NAME(m_btn_encrypt_run)]);
m_btn_encrypt_run.Update(true);
return true;
}
//------ Botones 2
//--- Referente al key
if(m_btn_encrypt_aleatorie_key.Id() == lparam)
{
const ENUM_CRYPT_METHOD method = ENUM_CRYPT_METHOD(m_combox_encrypt_type.GetListViewPointer().SelectedItemIndex() + 1);
g_mqlarticles_encryptor.SetAleatoryKey(method, Xoshiro256GenerateRandomUchar, &m_random, 35, 253);
m_edit_encrypt_key.SetValue(g_mqlarticles_encryptor.Key());
m_edit_encrypt_key.GetTextBoxPointer().Update(true);
}
if(m_btn_encrypt_key_show_hide.Id() == lparam)
{
// Edit
CTextBox* tb = m_edit_encrypt_key.GetTextBoxPointer();
const bool is_hidden = tb.Font() == EAFMOD_KEY_FONT;
tb.ChangeFont(is_hidden ? "Arial" : EAFMOD_KEY_FONT, 10);
// Boton
m_btn_encrypt_key_show_hide.SetImage(0, 0, g_llmagetn_tab_images_vis_path[is_hidden ? EAFMOD_FORKEYS_IMAGES_VIS_OPEN : EAFMOD_FORKEYS_IMAGES_VIS_CLOSED]);
m_btn_encrypt_key_show_hide.Update(true);
}
//---
return false;
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void CTabUtilsEncryther::OnRunEncrypt(void)
{
//--- Check
const string main_folder = m_general.MainFolder();
if(main_folder.Length() < 1)
{
MessageBox(GUIBASE_MSG("err_invalid_mfolder"), GUIBASE_COMMON("error"), MB_ICONERROR | MB_OK);
return;
}
//--- Vals
const ENUM_CRYPT_METHOD method = ENUM_CRYPT_METHOD(m_combox_encrypt_type.GetListViewPointer().SelectedItemIndex() + 1);
string key = m_edit_encrypt_key.GetValue(); // Le decimos que use la que tiene el encrypter
//--- Pregunamos si desea eliminar los archivos previos (esto es util solo si se espcifico una extension para la encryptacion)
const int res = MessageBox(GUIBASE_MSG("desea_eliminar_prev_folders"), GUIBASE_COMMON("info"), MB_ICONQUESTION | MB_YESNO);
//--- Si falla le decimos mensaje que revise logs
m_folder_encryptor.SetInitialPass();
if(!m_folder_encryptor.EncryptFolder(main_folder, m_general.ComonFlagVal(), key, method, (res == IDYES), m_edit_encrypt_prefix.GetValue()))
{
MessageBox(GUIBASE_MSG("err_encrypt_folder"), GUIBASE_COMMON("error"), MB_ICONQUESTION | MB_YESNO);
}
}
#endif // AIDATATASKRUNER_UI_TABUTIL_ENCRYPTER_MQH