2026-08-12 13:31:16 -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"
|
2026-08-26 08:21:19 -05:00 | | | #include <TSN\\BInt\\NUtils.mqh>
|
2026-08-12 13:31:16 -05:00 | | |
|
| | | //+------------------------------------------------------------------+
|
| | | //| Script program start function |
|
| | | //+------------------------------------------------------------------+
|
| | | void OnStart()
|
| | | {
|
| | | //---
|
| | | uchar data[];
|
| | | ArrayResize(data, 4);
|
| | | data[0] = 'h';
|
| | | data[1] = 'o';
|
| | | data[2] = 'l';
|
| | | data[3] = 'a';
|
| | |
|
| | | //---
|
| | | TSN::CChaCha20 cipher;
|
| | | uchar key[CHACHA20_KEYSIZEB] =
|
| | | {
|
| | | 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
|
| | | 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
|
| | | 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
|
| | | 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F
|
| | | };
|
| | | uchar iv[CHACHA20_IVNONE_B] =
|
| | | {
|
| | | 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96,
|
| | | 0xe9, 0x3d, 0x7e, 0x11
|
| | | };
|
| | |
|
| | | // cifrado
|
| | | cipher.Init(key, iv, 0);
|
| | | cipher.XProcces(data, 4);
|
| | | string out = "";
|
2026-08-26 08:21:19 -05:00 | | | TSN::CNumberUtils::BytesToHexLower(data, ArraySize(data), out);
|
2026-08-12 13:31:16 -05:00 | | | Print("Cifrado: ");
|
| | | Print(out);
|
| | |
|
| | | // descifrado
|
| | | cipher.Init(key, iv, 0);
|
| | | cipher.XProcces(data, 4);
|
| | | Print("DesCifrado: ");
|
| | | Print(CharArrayToString(data));
|
| | | }
|
| | | //+------------------------------------------------------------------+
|