base58Encode
Encodes a byte array into a Base58 string. This is a standalone utility function provided in base58.h and is essential for representing binary data, like public keys and signatures, in a human-readable format.
Parameters
| Parameter | Type | Description |
|---|---|---|
data | const uint8_t* | A pointer to the byte array to be encoded. |
len | size_t | The length of the byte array in bytes. |
Return Value
String: The Base58 encoded string representation of the input data.
Example Code (main.cpp)
#include <Arduino.h>
#include "base58.h" // Include the standalone header
void setup() {
Serial.begin(115200);
delay(1000);
Serial.println("\n=== base58Encode Example ===");
// Example data (20 bytes)
uint8_t dataToEncode[] = {
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09,
0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13
};
Serial.print("Original data (hex): ");
for(size_t i = 0; i < sizeof(dataToEncode); i++) {
if(dataToEncode[i] < 0x10) Serial.print("0");
Serial.print(dataToEncode[i], HEX);
}
Serial.println();
String encoded = base58Encode(dataToEncode, sizeof(dataToEncode));
Serial.println("✅ Encoded (Base58): " + encoded);
// Expected output for the above data starts with '16VN'
}
void loop() {
// Can be left empty
}