Expert Advisors • Indicators • Scripts • Libraries

MQL.RobotFX.org is the biggest collection of MetaTrader expert advisors (MT5 & MT4), indicators, scripts and libraries that can be used to improve trading results, minimize risks or simply automate trading tasks

MetaTrader 5 Libraries | SHA512 + HMAC

MetaTrader Experts, Indicators, Scripts and Libraries

The SHA512 class was ported from http://www.zedwood.com/article/cpp-sha512-function

HMAC functions were ported from https://en.wikipedia.org/wiki/Hash-based_message_authentication_code

Use example (tested on http://www.freeformatter.com/hmac-generator.html)

void OnStart()
{
        string in="Thanks for using!";
        string out=SHA512::sha512(in);
        Print("sha512('", in, "'): ", out);
        
        string key="hash_key";
        out=SHA512::hmac(in, key);
        Print("hmac-sha512: ", out);
}

OUTPUT
sha512('Thanks for using!'): efa2046d83de5504f28fc95e470e726f7f26f4a53475c516759a109a1553850e0836d1fb7a6ff54d27fa816e4ef8f93b6c63c8a133b3a39a8218313a506b870e
hmac-sha512: 61d45921efeb4fe22dc7f4afb393ddfc5603a5b1775cb377d0428d40fb49a8be89c606d89b3489a848105f67feeb329a7cda029d3b9b5f412436f87c016d83ed



--------------

Please leave a feedback and tell how you are using this class!
18158

Best MetaTrader Indicators + Profitable Expert Advisors