CryptoByLeo/Src/Padding/OAEP/Full.mq5

66 lines
2.2 KiB
MQL5
Raw Permalink Normal View History

2026-08-19 21:27:59 -05:00
//+------------------------------------------------------------------+
//| Full.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;
}
}
};
//+------------------------------------------------------------------+
//| Script program start function |
//+------------------------------------------------------------------+
void OnStart()
{
2026-08-20 17:22:07 -05:00
//--- mensaje
2026-08-19 21:27:59 -05:00
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);
2026-08-19 21:27:59 -05:00
//---
uchar coded[];
2026-08-20 17:22:07 -05:00
TSN::COAEP::Encode(mensaje, 256, random, TSN::CCryptoHashMeta::TSN_CRYPTO_HASH_TYPE_SHA256, coded);
2026-08-19 21:27:59 -05:00
//---
uchar out[];
const int t = TSN::COAEP::Decode(coded, 256, TSN::CCryptoHashMeta::TSN_CRYPTO_HASH_TYPE_SHA256, out);
//---
string str = "";
TSN::CNumberUtils::BytesToHexLower(out, t, str);
Print(str);
2026-08-20 17:22:07 -05:00
Print(CharArrayToString(out, 0, t)); // 2026.08.20 17:21:51.090 Full (EURUSD,H1) hola mundo
2026-08-19 21:27:59 -05:00
}
//+------------------------------------------------------------------+