Skip to content

mg_base64_decode() and binary #3123

Discussion options

You must be logged in to vote

https://mongoose.ws/documentation/#mg_base64_decode

#include "mongoose.h"

int main(void) {
  uint8_t buf[128];
  int len = mg_base64_decode("AAAAAAAAAAAA", 12, buf, 128);
  MG_INFO(("len: %d", len));
  mg_hexdump(buf, len);
  return 0;
}

$ ./b
28d889aa 2 b.c:7:main                   len: 9
0000   00 00 00 00 00 00 00 00 00 00                     ..........      
$ 

mongoose/src/base64.c

Lines 16 to 17 in f618fe1

if (c >= 'A' && c <= 'Z') {
return c - 'A';

'A' --> 0

We use base64 decoding in our HTML processing and in our TLS stack, and it serves its purpose

mongoose/src/base64.c

Lines 69 to 93 in f618fe1

size_t mg_base64_decode(const char *src, size_t n

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@Juggler-5
Comment options

@Juggler-5
Comment options

Answer selected by scaprile
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants