Skip to content

Commit

Permalink
update docs.
Browse files Browse the repository at this point in the history
  • Loading branch information
dojyorin authored May 26, 2023
1 parent 159a007 commit 6a52405
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 11 deletions.
9 changes: 4 additions & 5 deletions examples/decode/decode.ino
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@ void setup(){
Serial.begin(115200);
while(!Serial);

const char data[] = "F3c7EYKkxMgnvO0nB8FWVw==";
uint8_t result[base64::decodeLength(data)];
const char input[] = "F3c7EYKkxMgnvO0nB8FWVw==";
uint8_t output[base64::decodeLength(input)];
base64::decode(input, output);

base64::decode(data, result);

Serial.println((const char*)result);
Serial.println((const char*)output);
}

void loop(){}
11 changes: 5 additions & 6 deletions examples/encode/encode.ino
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@ void setup(){
Serial.begin(115200);
while(!Serial);

const uint8_t data[] = {0x17, 0x77, 0x3B, 0x11, 0x82, 0xA4, 0xC4, 0xC8, 0x27, 0xBC, 0xED, 0x27, 0x07, 0xC1, 0x56, 0x57};
auto dataLength = sizeof(data);
char result[base64::encodeLength(dataLength)];
const uint8_t input[] = {0x17, 0x77, 0x3B, 0x11, 0x82, 0xA4, 0xC4, 0xC8};
auto inputLength = sizeof(input);
char output[base64::encodeLength(inputLength)];
base64::encode(input, inputLength, output);

base64::encode(data, dataLength, result);

Serial.println(result);
Serial.println(output);
}

void loop(){}
14 changes: 14 additions & 0 deletions src/arduino_base64.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ namespace base64{
* If input is string, cast to `uint8_t*`.
* @example
* ```c++
* const uint8_t input[] = {0x17, 0x77, 0x3B, 0x11, 0x82, 0xA4, 0xC4, 0xC8};
* auto inputLength = sizeof(input);
* char output[base64::encodeLength(inputLength)];
* base64::encode(input, inputLength, output);
* ```
*/
void encode(const uint8_t* input, size_t inputLength, char* output);
Expand All @@ -21,6 +25,10 @@ namespace base64{
* Calculate number of output characters.
* @example
* ```c++
* const uint8_t input[] = {0x17, 0x77, 0x3B, 0x11, 0x82, 0xA4, 0xC4, 0xC8};
* auto inputLength = sizeof(input);
* char output[base64::encodeLength(inputLength)];
* base64::encode(input, inputLength, output);
* ```
*/
size_t encodeLength(size_t inputLength);
Expand All @@ -30,6 +38,9 @@ namespace base64{
* If output is string, cast to `char*`.
* @example
* ```c++
* const char input[] = "F3c7EYKkxMgnvO0nB8FWVw==";
* uint8_t output[base64::decodeLength(input)];
* base64::decode(input, output);
* ```
*/
void decode(const char* input, uint8_t* output);
Expand All @@ -38,6 +49,9 @@ namespace base64{
* Calculate number of output bytes.
* @example
* ```c++
* const char input[] = "F3c7EYKkxMgnvO0nB8FWVw==";
* uint8_t output[base64::decodeLength(input)];
* base64::decode(input, output);
* ```
*/
size_t decodeLength(const char* input);
Expand Down

0 comments on commit 6a52405

Please sign in to comment.