Libraries: Base64

 

Base64:

Simple coding/decoding of entries in Base64.

Author: Renat Fatkhullin

 

This library is not correct. Try the following:

string s;

s = CharToStr(65);

s = s + CharToStr(0);

s = s + CharToStr(66);

// in s variable will be "AB" not "A\x00B" (without 0 byte in the middle)! Therefore this code can not be valid.

How can I concatenate zero char in string? I am using MT4 4.00 build 218.

 

Thank you,

Milan

 
milanull:

This library is not correct. Try the following:

string s;

s = CharToStr(65);

s = s + CharToStr(0);

s = s + CharToStr(66);

// in s variable will be "AB" not "A\x00B" (without 0 byte in the middle)! Therefore this code can not be valid.

How can I concatenate zero char in string? I am using MT4 4.00 build 218.

Thank you,

Milan

 
your code is working fine for me. Thank you!
 

Thanks for this code, it's working nicely.

Is there any way to prevent the compile warnings? I'm seeing five occurrences of  'possible loss of data due to type conversion'.

Thanks. 

 

Do not use this library.

There is standard functionality for this:

 int h = FileOpen("/screenshot/"+filename, FILE_BIN|FILE_READ);
    FileReadArray(h, binarray, 0 , WHOLE_ARRAY);

    ArrayInitialize(key, 0x00);
    if(CryptEncode(CRYPT_BASE64, binarray, key, base64array) == 0)
      Print("Error encoding = ", GetLastError());

YOUR BASE64 String > CharArrayToString(base64array);
Reason: