When I published my code to protect an indicator / expert adviser I noticed an 'issue' I could not resolve. It is with the CryptDecode() function when decoding a BASE64 string.
If I encode a plain text string to BASE64 and then immediately decode that string, I get the same result. As it should be.
However, if I take a BASE64 encoded string as the input to the program and try to decode it, I *ALWAYS* get an error 4029 (Invalid array) error code. The code would be as follows:
I welcome any and all comments to this issue.
Thanks!
-Claude.
thanks for updating,i am reading and following you interestingly.
regards
When I published my code to protect an indicator / expert adviser I noticed an 'issue' I could not resolve. It is with the CryptDecode() function when decoding a BASE64 string.
If I encode a plain text string to BASE64 and then immediately decode that string, I get the same result. As it should be.
However, if I take a BASE64 encoded string as the input to the program and try to decode it, I *ALWAYS* get an error 4029 (Invalid array) error code. The code would be as follows:
I welcome any and all comments to this issue.
Thanks!
-Claude.
Because you need to drop the ending '0' character.
StringToCharArray(Input,src); ArrayResize(src,32);I will let you generalize the solution
Because you need to drop the ending '0' character.
I will let you generalize the solutionThanks Alain. I had a feeling you were the one that was going to answer this :)
Yeah...it's not funny, always the same
I know you are one of the top coders here and your input/comments are greatly appreciated by the community (even if you don't always get the "Thanks" you deserve).
But would it not make sense to omit the null character when converting a string to a character array? So the real bug would be in the StringCharToArray() function. We know that a string is always terminated by a null character, but a character array does not need the null character. So the function should strip that null character when converting a string to an array.
Your thought?
Thanks.
I know you are one of the top coders here and your input/comments are greatly appreciated by the community (even if you don't always get the "Thanks" you deserve).
But would it not make sense to omit the null character when converting a string to a character array? So the real bug would be in the StringCharToArray() function. We know that a string is always terminated by a null character, but a character array does not need the null character. So the function should strip that null character when converting a string to an array.
Your thought?
Thanks.
Yes, you can think about it like a bug in StringCharToArray(), but please don't report it to Metaquotes, they are able to fix it and broke existing codes
More seriously it's not a bug, it works as documented, and you could also specify the length of the string as a parameter to avoid the terminal 0.
When I published my code to protect an indicator / expert adviser I noticed an 'issue' I could not resolve. It is with the CryptDecode() function when decoding a BASE64 string.
If I encode a plain text string to BASE64 and then immediately decode that string, I get the same result. As it should be.
However, if I take a BASE64 encoded string as the input to the program and try to decode it, I *ALWAYS* get an error 4029 (Invalid array) error code. The code would be as follows:
I welcome any and all comments to this issue.
Thanks!
-Claude.
A trivial question as i don't have test this... but if you decode the code that contents another functions where do you print it in order to work? I mean, outside the Ontick function?
Thanks.
Regards
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
When I published my code to protect an indicator / expert adviser I noticed an 'issue' I could not resolve. It is with the CryptDecode() function when decoding a BASE64 string.
If I encode a plain text string to BASE64 and then immediately decode that string, I get the same result. As it should be.
However, if I take a BASE64 encoded string as the input to the program and try to decode it, I *ALWAYS* get an error 4029 (Invalid array) error code. The code would be as follows:
I welcome any and all comments to this issue.
Thanks!
-Claude.