CryptoByLeo/Src/Hash/Test/TestSHA3.mq5
Nique_372 ca93000d9d
2026-08-11 21:00:11 -05:00

60 lines
1.9 KiB
MQL5

//+------------------------------------------------------------------+
//| TestSHA3.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 "..\\SHA3.mqh"
//+------------------------------------------------------------------+
//| Script program start function |
//+------------------------------------------------------------------+
void OnStart()
{
//---
uchar fin[32];
int DataSizeMB = 8;
int dataSize = DataSizeMB * 1024 * 1024;
uchar data[];
ArrayResize(data, dataSize);
MathSrand(42);
for(int i = 0; i < dataSize; i++)
data[i] = (uchar)(MathRand() % 256);
ulong a = GetMicrosecondCount();
TSN::CCryptoHash::SHA3_256(data, dataSize, fin);
ulong b = GetMicrosecondCount();
double shaSeconds = (b - a) / 1000000.0;
double shaMBs = DataSizeMB / shaSeconds;
PrintFormat(" Tiempo: %.4f s", shaSeconds);
PrintFormat(" Velocidad: %.2f MB/s", shaMBs);
Print("fin: ", fin[0]);
/*string s = "SHA3 test MQL5 optimizado 2026";
uchar u[];
const int l = StringToCharArray(s, u) - 1;
TSN::CCryptoHash::SHA3_256(u, l, fin);
string str = "";
for(int i = 0; i < 32; i++)
{
str += StringFormat("%02x", fin[i]);
}
Print(str);*/
// f0f137d3c77e2db3093efe0fccd1a8078acd81978da5b627f5a89fce8e50c908
}
//+------------------------------------------------------------------+