83 lines
2.4 KiB
MQL5
83 lines
2.4 KiB
MQL5
//+------------------------------------------------------------------+
|
|
//| Test.mq5 |
|
|
//| Copyright 2026, Niquel Mendoza |
|
|
//| https://www.mql5.com |
|
|
//+------------------------------------------------------------------+
|
|
#property copyright "Copyright 2026, Niquel Mendoza"
|
|
#property link "https://www.mql5.com"
|
|
#property version "1.00"
|
|
#property strict
|
|
|
|
//+------------------------------------------------------------------+
|
|
//| |
|
|
//+------------------------------------------------------------------+
|
|
#include "Main.mqh"
|
|
|
|
//+------------------------------------------------------------------+
|
|
//| Script program start function |
|
|
//+------------------------------------------------------------------+
|
|
void OnStart()
|
|
{
|
|
//---
|
|
uchar key[32] =
|
|
{
|
|
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
|
|
0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
|
|
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
|
|
0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F
|
|
};
|
|
|
|
//---
|
|
uchar buf[16] =
|
|
{
|
|
0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96,
|
|
0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a
|
|
};
|
|
|
|
uchar copia2[16];
|
|
ArrayCopy(copia2, buf, 0, 0, 16);
|
|
|
|
//--- Inicializamos AES-256
|
|
TSN::CAes ae;
|
|
ae.Method(TSN::AES_CRYPTH_256);
|
|
|
|
//---
|
|
if(!ae.Init(key))
|
|
{
|
|
Print("Error al inicializar AES");
|
|
return;
|
|
}
|
|
|
|
//--- Test 2.
|
|
ulong dummy = 0;
|
|
|
|
ulong a = GetMicrosecondCount();
|
|
for(int i = 0; i < 100000; i++)
|
|
{
|
|
CryptEncode(CRYPT_AES256, copia2, key, copia2);
|
|
dummy += copia2[0];
|
|
}
|
|
ulong b = GetMicrosecondCount();
|
|
Print("Tiempo = ", (b - a), " dummy: ", dummy);
|
|
|
|
//--- Test 1.
|
|
dummy = 0;
|
|
|
|
a = GetMicrosecondCount();
|
|
for(int i = 0; i < 100000; i++)
|
|
{
|
|
ae.Cifrar(buf);
|
|
dummy += buf[0];
|
|
}
|
|
b = GetMicrosecondCount();
|
|
Print("Tiempo = ", (b - a), " dummy: ", dummy);
|
|
|
|
//---
|
|
a = GetMicrosecondCount();
|
|
for(int i = 0; i < 100000; i++)
|
|
ae.KeyExpansion(key); // esto SÍ rehace el KeyExpansion cada vez
|
|
b = GetMicrosecondCount();
|
|
Print("Solo Init (con KeyExpansion) 100000 = ", (b - a));
|
|
}
|
|
//+------------------------------------------------------------------+
|
|
//+------------------------------------------------------------------+
|