B4R Code Snippet Base64 encode via Inline C

KMatle

Expert
Licensed User
B4R code (Vars in Process_Globals)

B4X:
Dim b64encoded(1024) As Byte
Dim b64toencode(1024) As Byte
Call

B4X:
bc.ArrayCopy2("Test",0,b64toencode,0,buf.Length)
RunNative("B64", Null)
You need the RandomAccess lib to use the ByteConverter


Include

B4X:
#include <base64.h>

C code

B4X:
void B64 (B4R::Object* o) {

  printf("B64...\n");
  /*String toEncode = "Test";*/
  char toEncode[1024];
  memcpy(toEncode,b4r_main::_b64toencode->data,1024);
 
 
  String encoded = base64::encode(toEncode);
 
  /*printf("Encoded: %s\n", encoded);*/
    
  Serial.println(encoded);

  printf("\n");
 
  memcpy(b4r_main::_b64encoded->data, encoded.c_str(),strlen(encoded.c_str()));

}
PS: As it seems, the Class can encode but not decode
 
Top