Teach how to hash data in mql4

 
Comments not related to "Bitcoin and everything to do with it have been moved to this thread.The home of cryptomaniacs and their adversaries.".
 
Fellow programmers, teach me how to hash data in mql4 (I seem to know how to use base64)
 
Mischek:
Yeah, they're looking for younger people now.
"old horse don't mess around" (folk)
 
sanyooooook:
Comrade citizen programmers teach me how to hash the data on mql4 (I seem to know how to use base64)
MD5 ?
 
sergeev:
MD5 is needed ?

MD5 I think I found an example somewhere.


sha256

I haven't dealt with it so for the most part I don't even know what's needed - here's a code example on the sprp:

protected string Login= "Получить на странице доступа к API";
    protected string Password = ""Получить на странице доступа к API";
    protected string Culture ="ru-RU";

    var RequestBalance = new { Login = Login, Wmid = wmid, Culture = Culture, Signature = HashToBase64(String.Format("{0};{1};{2};{3}", Login, Password, Culture, wmid), null)};
    string Response = ITServiceJson.Balance(ForceJson(RequestBalance));

 static public byte[] Hash(string plainString, Encoding encoding)
    {
      if (plainString == null)
        throw new ArgumentNullException("plainString");

      if (encoding == null)
        encoding = Encoding.UTF8;

      return Hash(encoding.GetBytes(plainString));
    }

    static public byte[] Hash(byte[] bytes)
    {
      if (bytes == null)
        throw new ArgumentNullException("bytes");
      using (SHA256 algorithm = new SHA256Managed())
      {
        byte[] hashBytes = algorithm.ComputeHash(bytes);
        return hashBytes;
      }
    }

    public string HashToBase64(string plainString, Encoding encoding)
    {
      if (plainString == null) throw new ArgumentNullException("plainString");
      return Convert.ToBase64String(Hash(plainString, encoding));
    }
  
 

I've figured out how to send a post request, but I need to make a hash here Signature:

name destination note
Login trader login is given to the trader on the API access page and is used to sign requests to the online exchange.
Password trader password obtained by trader on the API access page and used to sign requests to the online-exchange
Wmid Trader's Wmid WM identifier of the trader, when working with the online-exchange
Culture query language Defines the message language. (ru-RU, en-EN)
Signature request signature generated from parameters: Login + ';' + Password + ';' + Culture + ';' +Wmid
 
sergeev:
MD5 ?
No not MD5 exactly
 
SHA-256 Source Code (SHA2) - PolarSSL
SHA-256 Source Code (SHA2) - PolarSSL
  • Offspark B.V.
  • tls.mbed.org
In addition to being used for the SHA-256 algorithm, the same code also performs the SHA-224 algorithm. In fact, the SHA-224 hash algorithm is nothing more than the result of the SHA-256 algorithm being cut short. The code only has a single dependency on config.h in the sha2.c source code file. You can remove this inclusion or just create a...
 

I, being naive, wanted a ready-made one.

I was naive, I wanted a ready-made one.

ZS: maybe winds has some built-in libraries that do this encryption.

Sorry about the misspelling.

 
sanyooooook:

Write in Sharpe, Sanek, you don't have to think much there.

I'm already on my 4th exchange, I'm implementing the api :)

sanyooooook:

ZS: maybe Windows has some built-in libraries that do such encryption.

CryptoAPI
The Cryptography API, or How to Keep a Secret
The Cryptography API, or How to Keep a Secret
  • msdn.microsoft.com
This article describes the Microsoft® Cryptography application programming interface (API) that is available with the new Windows NT® version 4.0 release and upcoming versions of Windows® 95. This article examines what is required to set up and use this new API. In order to compile the sample application you will need Microsoft Visual C++®...
 
TheXpert:

Write in Sharp, Sanek, you don't have to think much there.


It's hard for me to change, that's why I'm still on mucl4
Reason: