2026-09-02 11:55:03 -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 "..\\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 = "";
|
2026-09-26 21:47:11 -05:00 | | | TSN::CHexUtils::BytesToHexLower(tok, t, out);
|
2026-09-02 11:55:03 -05:00 | | | Print(out);
|
| | |
|
| | |
|
| | | //
|
| | | uchar msg[];
|
| | | t = fernet.DecryptRaw(tok, t, msg, INT_MAX);
|
| | |
|
| | | Print(CharArrayToString(msg, 0, t));
|
| | |
|
| | | }
|
| | | //+------------------------------------------------------------------+
|
| | |
|
| | |
|
| | |
|