89 lines
3 KiB
MQL5
89 lines
3 KiB
MQL5
//+------------------------------------------------------------------+
|
|
//| Base.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_HASH_BASE_MQH
|
|
#define CRYPTOBYLEO_SRC_HASH_BASE_MQH
|
|
|
|
//+------------------------------------------------------------------+
|
|
//| |
|
|
//+------------------------------------------------------------------+
|
|
namespace TSN
|
|
{
|
|
class CCryptoHash
|
|
{
|
|
private:
|
|
//--- internas
|
|
static void SHA3_KECCAK_F(ulong &s[]);
|
|
|
|
public:
|
|
CCryptoHash(void) {}
|
|
~CCryptoHash(void) {}
|
|
//---
|
|
// SHA3 Famiy
|
|
static void SHA3_HASH(const uchar &in[], int ins, uchar &out[], int outl, int chunk_t, uchar delim);
|
|
// especifico
|
|
static __forceinline void SHA3_256(const uchar &in[], int ins, uchar &out[]);
|
|
static __forceinline void SHA3_512(const uchar &in[], int ins, uchar &out[]);
|
|
static __forceinline void SHAKE128(const uchar &in[], int ins, uchar &out[], int outl);
|
|
static __forceinline void SHAKE256(const uchar &in[], int ins, uchar &out[], int outl);
|
|
|
|
//--- SHA2
|
|
static void SHA256(const uchar &inp[], int ins, uchar& out[]);
|
|
|
|
// sha2 high family
|
|
static void SHA2_HIGH(ulong& h[], const uchar &inp[], int ins); // funcion base de bajo nivel
|
|
static void SHA512(const uchar &inp[], int ins, uchar& out[]);
|
|
static void SHA384(const uchar &inp[], int ins, uchar& out[]);
|
|
|
|
//--- BLAKE
|
|
static void BLAKE2B(const uchar &in[], int ins, uchar &out[], int outl = 64);
|
|
|
|
//--- Extra internal
|
|
static void Expand8To32(uint32_t &in[], uint8_t& out[]);
|
|
static void Expand8To32(uint64_t &in[], uint8_t& out[]);
|
|
};
|
|
|
|
//+------------------------------------------------------------------+
|
|
//| |
|
|
//+------------------------------------------------------------------+
|
|
// Esto en BE no es LE
|
|
static void CCryptoHash::Expand8To32(uint &in[], uchar &out[])
|
|
{
|
|
//--- BE
|
|
#define CRYPTOHASHBYLEO_HASH_ASSING(INDEX) \
|
|
out[INDEX] = uint8_t(t >> 24); \
|
|
out[INDEX+1] = uint8_t(t >> 16); \
|
|
out[INDEX+2] = uint8_t(t >> 8); \
|
|
out[INDEX+3] = uint8_t(t);
|
|
|
|
//---
|
|
uint32_t t = in[0];
|
|
CRYPTOHASHBYLEO_HASH_ASSING(0)
|
|
t = in[1];
|
|
CRYPTOHASHBYLEO_HASH_ASSING(4)
|
|
t = in[2];
|
|
CRYPTOHASHBYLEO_HASH_ASSING(8)
|
|
t = in[3];
|
|
CRYPTOHASHBYLEO_HASH_ASSING(12)
|
|
t = in[4];
|
|
CRYPTOHASHBYLEO_HASH_ASSING(16)
|
|
t = in[5];
|
|
CRYPTOHASHBYLEO_HASH_ASSING(20)
|
|
t = in[6];
|
|
CRYPTOHASHBYLEO_HASH_ASSING(24)
|
|
t = in[7];
|
|
CRYPTOHASHBYLEO_HASH_ASSING(28)
|
|
|
|
//---
|
|
#undef CRYPTOHASHBYLEO_HASH_ASSING
|
|
}
|
|
}
|
|
|
|
#endif // CRYPTOBYLEO_SRC_HASH_BASE_MQH
|
|
//+------------------------------------------------------------------+
|