//+------------------------------------------------------------------+ //| Main.mqh | //| Copyright 2026, Niquel Mendoza | //| https://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "Copyright 2026, Niquel Mendoza" #property link "https://www.mql5.com" #property strict #ifndef CRYPTOBYLEO_SRC_MGF1_MAIN_MQH #define CRYPTOBYLEO_SRC_MGF1_MAIN_MQH //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ #include "Def.mqh" //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ namespace TSN { //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void MGF1(const uchar& seed[], int seeds, int outl, uchar& outm[], CCryptoHashMeta::ENUM_TSN_CRYPTO_HASH f) { //---- const int hlen = TSN::CCryptoHashMeta::g_crytpo_hash_meta[f].outl; // tamaño de salida const CCryptoHashMeta::TsnCryptoByLeoHashFuncFixed fhash = TSN::CCryptoHashMeta::g_crypto_fhash_fixed[f]; //--- buffer base uchar buf[]; const int bufs = ArrayResize(buf, seeds + 4); for(int i = 0; i < seeds; i++) buf[i] = seed[i]; // copiamos //--- buffer del reuslto del hasher uchar buf_hash_ou[]; ArrayResize(buf_hash_ou, hlen); //--- uint32_t counter = 0; int w = 0; // incide de escrituira //--- numero de bloques a procesar const uint nblocks = uint((outl + (hlen - 1)) / hlen); // ceil.. //-- for(uint32_t counter = 0; counter < nblocks; counter++) { // añadimos el contador buf[seeds] = uchar(counter >> 24); buf[seeds + 1] = uchar(counter >> 16); buf[seeds + 2] = uchar(counter >> 8); buf[seeds + 3] = uchar(counter); // aplicamos hasher fhash(buf, bufs, buf_hash_ou); // truncamos si hace falta (en caso sobrepase solo tomaoms lo necsario) const int chunk = (w + hlen > outl) ? (outl - w) : hlen; // copiamos datos for(int i = 0; i < chunk; i++) outm[w + i] = buf_hash_ou[i]; // aumentamos w += chunk; } } } //+------------------------------------------------------------------+ #endif // CRYPTOBYLEO_SRC_MGF1_MAIN_MQH