Other 'decode' is not a member of 'base64'

KMatle

Expert
Licensed User
First: I'm really not a pro in using C++ :D

I'm using this code to en-/decode to/from Base64 strings. The compiler says, that it can't find the decode method. Any ideas?

B4X:
#include "base64.h"

...
...

void b64 (B4R::Object* o) {

  String toEncode = "Test encoding";
  String encoded = base64::encode(toEncode); 'works
  Serial.println(encoded);
 
  size_t outputLength;
  unsigned char * decoded = base64::decode((unsigned char *)encoded.c_str(),      strlen(encoded.c_str()), &outputLength);
  Serial.print("Length of decoded message: ");
  Serial.println(outputLength);
  Serial.printf("%.*s", outputLength, decoded);
  free(decoded);

}
B4X:
b4r_encryption.cpp:48:29: error: 'decode' is not a member of 'base64'

base64.h:

B4X:
/*
 * Base64 encoding/decoding (RFC1341)
 * Copyright (c) 2005, Jouni Malinen <j@w1.fi>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 *
 * Alternatively, this software may be distributed under the terms of BSD
 * license.
 *
 * See README and COPYING for more details.
 */

#ifndef BASE64_H
#define BASE64_H

unsigned char * base64_encode(const unsigned char *src, size_t len,
                  size_t *out_len);
unsigned char * base64_decode(const unsigned char *src, size_t len,
                  size_t *out_len);

#endif /* BASE64_H */
 

thetahsk

Active Member
Licensed User
First: I'm really not a pro in using C++ :D

I'm using this code to en-/decode to/from Base64 strings. The compiler says, that it can't find the decode method. Any ideas?
..
check your include file in...\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.2\cores\esp32\base64.h
B4X:
#ifndef CORE_BASE64_H_
#define CORE_BASE64_H_

class base64
{
public:
    static String encode(uint8_t * data, size_t length);
    static String encode(String text);
private:
};


#endif /* CORE_BASE64_H_ */
You must include crypto/base64.h
 
Last edited:
Top