You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
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!
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!
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.
This way, all possible encryptions (except the hashes of course) are reversible.
I think might my code can help a little
I am facing issue with MQL4 encryption. Please see above code, the expected output vs actual. Why is the Base64 not matching? To be specific, the last part of the base64s are not matching. Any help will be greatly appreciated.
I was thrown off on the same issue when checking with an online tool for decoding/encoding. The problem is in PHP ( which is likely what you come across if you look online) is that there are more options than MQL4.
PHP:
$key = "01234567890123456789012345678901";
$method = "AES-256-ECB";
$out = openssl_decrypt ($in, $method , $key, OPENSSL_ZERO_PADDING);
will work with your MQL4 solution, however:
$out = openssl_decrypt ($in, $method , $key);
will not, the onlne tool you used probably did not have the "OPENSSL_ZERO_PADDING" flag set.
Thanks Michael for your response. The online tool(I used https://www.devglan.com/online-tools/aes-encryption-decryption) is having only limited options. So I have tried this using Ruby language.
Following is the MQL4 code base:
Following is the equivalent Ruby code base:
Output from MQL4 and Ruby. Any help what is happening here? In Ruby there is no option to set any Padding:
MT4 B64 - NsFJlGQScUEazmSEykVeO8+GIc+waNCNu4TUsr7v7yjJd+HmS5mZCcoTvtTHaIxk Ruby B64 - NsFJlGQScUEazmSEykVeO8+GIc+waNCNu4TUsr7v7yhEQLoJ+XRFSpMaG3G8\nTkxT\n online - NsFJlGQScUEazmSEykVeO8+GIc+waNCNu4TUsr7v7yhEQLoJ+XRFSpMaG3G8TkxT // This is the online tool output which is irrelevant for this discussion, however just sharing
Again, the MT4 Base64 and Ruby Base64 are different, specifically the last part. What am I missing? Do I need to do something on Ruby side or MQL4 side?