教你如何在mql4中进行数据哈希运算

 
 
各位 程序员,教我如何在mql4中哈希数据(我似乎知道如何使用base64)。
 
Mischek:
是的,他们现在正在寻找年轻的人。
"老马不乱"(民谣)
 
sanyooooook:
公民程序员同志 教我如何在mql4上哈希数据(我似乎知道如何使用base64)。
MD5 ?
 
sergeev:
需要MD5吗?

MD5我想我在什么地方找到了一个例子。


沙256

我没有和它打过交道,所以在大多数情况下,我甚至不知道需要什么--这里有一个关于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));
    }
  
 

我已经知道了如何发送一个帖子请求,但我需要在这里做一个哈希的签名。

名称 目的地 备注
登录 交易员登录 是在API访问页面上给交易商的,用于签署对在线交易所的请求。
密码 交易员密码 由交易员在API访问页面上获得,并用于签署对在线交易所的请求。
纬度 交易员的Wmid 当与在线交易所合作时,交易商的WM标识符。
文化 查询语言 定义了信息的语言。(ru-RU, en-EN)
签名 请求签名 参数 中生成: Login +';' + Password + ';' + Culture + ';' +Wmid
 
sergeev:
MD5 ?
不完全是MD5
 
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...
 

我太天真了,想要一个现成的。

我太天真了,我想要一个现成的。

ZS: 也许winds有一些内置的库可以做这种加密。

对拼写错误感到抱歉。

 
sanyooooook:

写在夏普,萨内克,你不必在那里多想。

我已经是第4次交换了,我正在实施api :)

sanyooooook:

ZS:也许Windows有一些内置的库可以做这种加密。

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:

用Sharp写,Sanek,你不必在那里多想。


我很难改变,这就是为什么我还在使用mucl4。