B4R Code Snippet Base64 encode via Inline C

Discussion in 'B4R Code Snippets' started by KMatle, Apr 13, 2019.

Tags:
  1. KMatle

    KMatle Expert Licensed User

    B4R code (Vars in Process_Globals)

    Code:
    Dim b64encoded(1024As Byte
    Dim b64toencode(1024As Byte
    Call

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


    Include

    Code:
    #include <base64.h>

    C code

    Code:
    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
     
    hatzisn, Peter Simpson and Erel like this.
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice