2026-09-02 15:54:33 -05:00 | | | //+------------------------------------------------------------------+
|
2026-03-27 09:40:26 -05:00 | | | //| TestDec.mq5 |
|
| | | //| 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 version "1.00"
|
| | | #property strict
|
| | |
|
| | | //+------------------------------------------------------------------+
|
| | | //| |
|
| | | //+------------------------------------------------------------------+
|
| | | #include "..\\FolderEncrypt.mqh"
|
2026-09-02 15:54:33 -05:00 | | | // incluimos PRNG random
|
| | | #include <TSN\\Crypto\\URandomPRNG.mqh>
|
| | | // Xoshiro256 para random
|
| | | #include <TSN\\Random\\Xoshiro256.mqh>
|
2026-03-27 09:40:26 -05:00 | | |
|
| | | //+------------------------------------------------------------------+
|
| | | //| Script program start function |
|
| | | //+------------------------------------------------------------------+
|
| | | void OnStart()
|
| | | {
|
| | | //---
|
| | | const string folder_path = "MQLArticles\\File\\FolderOps\\Enc\\";
|
2026-09-02 15:54:33 -05:00 | | |
|
| | | //--- Random para el IV
|
| | | TSN::CURandomPRNG<Xoshiro256>::s_rand.Seed(1000);
|
| | | // key 0 para reproducibilidad
|
| | | uchar key[CRYPTOBYLEO_FERNET_KEYBYTES];
|
| | | ArrayInitialize(key, 0);
|
| | |
|
| | | //---
|
| | | TSN::CFernet fernet;
|
| | | fernet.Key(key);
|
2026-03-27 09:40:26 -05:00 | | |
|
| | | //---
|
2026-09-02 15:54:33 -05:00 | | | TSN::CFolderOpsEncrypt folder_dec;
|
| | | folder_dec.AddLogFlags(LOG_ALL);
|
| | | folder_dec.Fernet(&fernet);
|
| | | folder_dec.SizeArrInclued(2);
|
| | | folder_dec.SetValIncluyed(0, "*.txt.enc");
|
| | | folder_dec.SetValIncluyed(1, "*.csv.enc");
|
| | | folder_dec.SetInitialPass();
|
| | | Print(folder_dec.DecryptFolder(folder_path, true, true, INT_MAX, "-"));
|
2026-03-27 09:40:26 -05:00 | | |
|
| | | //--- Verificamos contenido
|
| | | const string files[] = {"data_importante.txt", "data_importante.csv"};
|
| | | for(int i = 0; i < ArraySize(files); i++)
|
| | | {
|
2026-09-02 15:54:33 -05:00 | | | ::ResetLastError();
|
2026-03-27 09:40:26 -05:00 | | | int fh = FileOpen(folder_path + files[i], FILE_READ | FILE_TXT | FILE_COMMON);
|
| | | if(fh == INVALID_HANDLE)
|
| | | {
|
2026-09-02 15:54:33 -05:00 | | | Print("Fallo al abrir = ", files[i], " | last err = ", ::GetLastError());
|
2026-03-27 09:40:26 -05:00 | | | continue;
|
| | | }
|
| | | Print(files[i], " = ", FileReadString(fh));
|
| | | FileClose(fh);
|
| | | }
|
| | | }
|
| | | //+------------------------------------------------------------------+
|