B4R Question Native C: How to use Strings/Chars?

Discussion in 'B4R Questions' started by KMatle, Mar 17, 2019.

Tags:
  1. KMatle

    KMatle Expert Licensed User

    I'm working on how to use AES with an ESP32. Everything is fine except how to use/return strings (byte arrays/chars). There are some threads but I don't get it.

    Code:

    Code:
    Private enc() As Byte ' In Globals

    RunNative(
    "InitAES",Null' Call
    Inline C

    Code:
    #if C
    #include <mbedtls/aes.h>

    char rstr[50];

    void InitAES (B4R::Object* o) {
    b4r_main::_enc = rstr;


    }
    #End if
    Error:
    Code:
    b4r_main.cpp:61: error: cannot convert 'char [50]' to 'B4R::Array*' in assignment
    I simply need to return "rstr" to "enc"
     
  2. thetahsk

    thetahsk Active Member Licensed User

    Try this

    Code:
    b4r_main::_enc->data = rstr;
    b4r_main::_enc->length = strlen(rstr);
     
    Last edited: Mar 17, 2019
    KMatle likes this.
  3. KMatle

    KMatle Expert Licensed User

    Thanks. That worked.
     
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