Download MetaTrader 5

CryptEncode without using a key ?

To add comments, please log in or register
Use the Pocket to paste your content. It is convenient!
Sol Dev
833
Sol Dev 2015.12.06 19:41 

Hello, i got a string to encode into SHA-256. For this, i'm using the CryptEncode function with my string converted to char array.

I do not need to encrypt this array with any key, as the key is already hand crafted into this string (this is something i cant change).

Example :

StringToCharArray(_tohash,src);
StringToCharArray(_saltkey,key);

where :

string _saltkey = "1234";
string _tohash = "my message to be encrypted"+_mysaltkey;

I dont understand why my hashed result returned by :

CryptEncode(CRYPT_HASH_SHA256,src,key,_hashed);

is different from using an online hash online utility like this :

I think it may have something to deal with the "key" in CryptEncode function, so is there a way to use it without any key while not altering the result, which has to be the same as an online PHP generator.

I would appreciate any help, as i am really stuck right now :'( Thanks !



Alain Verleyen
Moderator
30755
Alain Verleyen 2015.12.06 20:23  
StringToCharArray(_tohash,src);

should be

   StringToCharArray(_tohash,src,0,StringLen(_tohash));

and you have an error :

string _saltkey = "1234";
string _tohash = "my message to be encrypted"+_mysaltkey;
Sol Dev
833
Sol Dev 2015.12.06 22:19  
Alain Verleyen:

should be

and you have an error :

Thanks a lot Alain. It does now work perfectly !
To add comments, please log in or register