CryptoByLeo/Src/Padding/OAEP/Test.mq5

67 lines
2.1 KiB
MQL5
Raw Permalink Normal View History

2026-08-19 17:43:41 -05:00
//+------------------------------------------------------------------+
//| 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"
#include <TSN\\BInt\\NUtils.mqh>
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
class CRandomTest
{
public:
CRandomTest(void) {}
~CRandomTest(void) {}
static void Random(uchar& out[], int olt, int i)
{
olt += i;
for(; i < olt; i++)
{
out[i] = 0xAA;
}
}
};
2026-08-19 17:43:41 -05:00
//+------------------------------------------------------------------+
//| Script program start function |
//+------------------------------------------------------------------+
void OnStart()
{
2026-08-20 17:22:07 -05:00
//--- mensaje
string mensaje_str = "hola mundo";
uchar mensaje[];
StringToCharArray(mensaje_str, mensaje, 0, StringLen(mensaje_str));
2026-08-20 17:22:07 -05:00
//--- random
uchar random[];
ArrayResize(random, CRYPTOBYLEO_SHA256_SIZET_FHASH);
CRandomTest::Random(random, CRYPTOBYLEO_SHA256_SIZET_FHASH, 0);
//---
uchar coded[];
ulong a = GetMicrosecondCount();
for(int i = 0; i < 5000; i++)
{
2026-08-20 17:22:07 -05:00
TSN::COAEP::Encode(mensaje, 256, random, TSN::CCryptoHashMeta::TSN_CRYPTO_HASH_TYPE_SHA256, coded);
}
ulong b = GetMicrosecondCount();
Print("time: ", (b - a));
2026-08-19 17:43:41 -05:00
//---
string str = "";
TSN::CNumberUtils::BytesToHexLower(coded, 256, str);
Print(str[0]);
2026-08-19 17:43:41 -05:00
}
//+------------------------------------------------------------------+