Download MetaTrader 5

Error CryptDecode - page 3

To add comments, please log in or register
asurething
8
asurething  
All sorted!

Thank you SO much Alain.

My excuse was being 7 days into a software bender that was all VB except for the MQL4 module that was left till the end :)

I did try creating a HexToArray function but could not get it to work. This is my first time on the forum and I really appreciate the support, I also like your style, not spoon-feeding us with solutions but providing pointers in the right direction so we have to work it out and therefore gain a deeper understnading of the issue.

I knew what I wanted to achieve but yesterday could not see the wood for the trees.

Next time I'll remember to format the posts correctly, its a really neat editor.

Phill!
Alain Verleyen
Moderator
33334
Alain Verleyen  
asurething:
All sorted!

Thank you SO much Alain.

My excuse was being 7 days into a software bender that was all VB except for the MQL4 module that was left till the end :)

I did try creating a HexToArray function but could not get it to work. This is my first time on the forum and I really appreciate the support, I also like your style, not spoon-feeding us with solutions but providing pointers in the right direction so we have to work it out and therefore gain a deeper understnading of the issue.

I knew what I wanted to achieve but yesterday could not see the wood for the trees.

Next time I'll remember to format the posts correctly, its a really neat editor.

Phill!
Welcome. Happy to help.
chinaski
922
chinaski  

I stumbled over same problem and found that the origin of this problem is the function

StringToCharArray

which also copies the termination zero to uchar array. So the string + 0 . The example exposed on

https://docs.mql4.com/common/cryptencode

can't work. You need to replace

StringToCharArray

by your own function, not copying termination 0 to array because this is done in StringToCharArray. 

int my_StringToCharArray(string& source,uchar& dest[])
{
   int len=StringLen(source);
   if(len > 0)
   {
      StringToCharArray(source,dest,0,len); 
   }
   return len;
}

This way, all possible encryptions (except the hashes of course) are reversible.

CryptEncode - Common Functions - MQL4 Reference
CryptEncode - Common Functions - MQL4 Reference
  • docs.mql4.com
CryptEncode - Common Functions - MQL4 Reference
Romeu Bertho
3160
Romeu Bertho  

I think might my code can help a little

123
To add comments, please log in or register