68 líneas
1,9 KiB
MQL5
68 líneas
1,9 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"
|
||
|
|
#include "..\\URandom\\PRNG.mqh"
|
||
|
|
|
||
|
|
//+------------------------------------------------------------------+
|
||
|
|
//| |
|
||
|
|
//+------------------------------------------------------------------+
|
||
|
|
class CFiller
|
||
|
|
{
|
||
|
|
public:
|
||
|
|
CFiller(void) {}
|
||
|
|
~CFiller(void) {}
|
||
|
|
|
||
|
|
static void RandomCryptoBytes(uchar& out[], int oult, int o_s = 0)
|
||
|
|
{
|
||
|
|
ArrayFill(out, o_s, oult, 0);
|
||
|
|
}
|
||
|
|
};
|
||
|
|
|
||
|
|
//+------------------------------------------------------------------+
|
||
|
|
//| Script program start function |
|
||
|
|
//+------------------------------------------------------------------+
|
||
|
|
void OnStart()
|
||
|
|
{
|
||
|
|
//---
|
||
|
|
TSN::CFernet fernet;
|
||
|
|
|
||
|
|
// key
|
||
|
|
fernet.Key<CFiller>();
|
||
|
|
|
||
|
|
// in
|
||
|
|
string text = "Hola mundo";
|
||
|
|
uchar in[];
|
||
|
|
StringToCharArray(text, in, 0, StringLen(text), CP_UTF8);
|
||
|
|
|
||
|
|
// tok
|
||
|
|
uchar tok[];
|
||
|
|
int t = fernet.EncryptRaw<CFiller>(in, tok, 1700000000);
|
||
|
|
//Print(t);
|
||
|
|
|
||
|
|
string out = "";
|
||
|
|
TSN::CNumberUtils::BytesToHexLower(tok, t, out);
|
||
|
|
Print(out);
|
||
|
|
|
||
|
|
|
||
|
|
//
|
||
|
|
uchar msg[];
|
||
|
|
t = fernet.DecryptRaw(tok, t, msg, INT_MAX);
|
||
|
|
|
||
|
|
Print(CharArrayToString(msg, 0, t));
|
||
|
|
|
||
|
|
}
|
||
|
|
//+------------------------------------------------------------------+
|
||
|
|
|
||
|
|
|
||
|
|
|