Fast cryptographic library for MQL5 (Hashes [SHA3, SHA2, BLAK2]) (HMAC) (Simetric Cipher - AES - CHACHA20) (Asymetric Chiper ) (Padding (OAEP)) (MaskFunction (MGF1))
  • MQL5 87.1%
  • MQL4 12.9%
Buscar un archivo
Archivos del repositorio (primero la última confirmación)
Nombre del archivo Mensaje del último instantánea Fecha de la última instantánea
Nique_372 17ce61d3e3
2026-08-26 22:23:21 -05:00
Src 2026-08-26 22:23:21 -05:00
Wf 2026-08-26 10:58:53 -05:00
CryptoByLeo.mqproj Generated by MQL5 Wizard 2026-08-10 15:56:21 -05:00
dependencies.json add new dep 2026-08-25 08:26:05 -05:00
LICENSE Añadir LICENSE 2026-08-10 21:10:19 +00:00
README.md 2026-08-26 13:35:15 -05:00

Fast cryptographic library for MQL5: hashes, HMAC, symmetric and asymmetric ciphers, padding and RSP test vector parsing.
Pure MQL5, no DLLs required for the crypto primitives themselves.


Main Features

  • Hashes: SHA-2 (SHA256/384/512), SHA-3 (incl. SHAKE128/256), BLAKE2b
  • HMAC: generic HMAC construction over any supported hash function
  • Symmetric ciphers: AES (128/256) and ChaCha20
  • Asymmetric cipher (RSA): key generation, encryption/decryption and signing — ~90% complete
  • Padding schemes: OAEP, PSS and PKCS#1 v1.5
  • Mask generation function: MGF1
  • RSP parser: fast parser for .rsp NIST test vector files, used to validate hash implementations
  • PRNG: pseudo-random byte generator (CPseudoAleatorio) with Windows bcrypt.dll entropy import

Usage examples

Hashing (SHA-3-256):

#include "Src\\Hash\\SHA3.mqh"

uchar data[] = { /* ... */ };
uchar out[32];

TSN::CCryptoHashSHA3::SHA3_256(data, ArraySize(data), 0, out);

PSS padding encode (for RSA signing):

#include "Src\\Padding\\PSS\\Main.mqh"

uchar msg[], salt[], out[];
// ...
int len = TSN::CPSS::Encode(msg, msg_hash_len, salt, em_bits,
                             TSN::CCryptoHashMeta::TSN_CRYPTO_HASH_TYPE_SHA256, out);

Pseudo-random bytes:

#include "Src\\PseAle\\Main.mqh"

uchar raw[16];
TSN::CPseudoAleatorio::R1(raw, 16, 0);

Repository Structure

CryptoByLeo/
├── Src/
│   ├── Hash/       # SHA-2, SHA-3, BLAKE2b
│   ├── MAC/        # HMAC
│   ├── MGF1/       # Mask generation function
│   ├── Padding/    # OAEP, PKCS1v15, PSS
│   ├── PseAle/     # Pseudo-random byte generator
│   ├── RSA/        # Key generation, sign/enc/dec
│   ├── RSPParser/  # .rsp NIST test vector parser
│   ├── Simetric/   # AES, ChaCha20
│   └── Imports/    # External DLL imports (bcrypt.dll)
└── Wf/             # Workflow / integration test EA

Requirements

See dependencies.json for the full list.


Installation

cd "C:\Users\YOUR_USER\AppData\Roaming\MetaQuotes\Terminal\YOUR_ID\MQL5\Shared Projects"
tsndep install "https://forge.mql5.io/nique_372/CryptoByLeo.git"

Requires the tsndep package, available on PyPI. It automatically downloads and installs all declared dependencies.


Quick Start

1. Include the module you need:

#include "..\\CryptoByLeo\\Src\\Hash\\All.mqh"

2. Use it:

uchar out[32];
TSN::CCryptoHashSHA3::SHA3_256(data, ArraySize(data), 0, out);

License

Read Full License By downloading or using this repository, you accept the license terms.


Contact


Roadmap

  • Hashes (SHA-2, SHA-3, BLAKE2b), HMAC, AES, ChaCha20, Padding (OAEP/PSS/PKCS1v15), MGF1, RSP parser [Complete]
  • RSA (key generation, sign/enc/dec) [~90%, in progress]
  • Test suite coverage [~70%, in progress]

Copyright © 2026 Niquel & Leo — TSN Ecosystem