skullchap / b64

base64 single header encode/decode

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

b64.h

base64 single header encode/decode

Works with C89

#include <stdio.h>
#include "b64.h"

int main(int argc, char **argv)
{
// External buffer
    char b64enc[1024];
    char b64dec[1024];
    
    b64Encode(b64enc, argv[1], strlen(argv[1]));
    printf("%s\n", b64enc);
    
    b64Decode(b64dec, b64enc, strlen(b64enc));
    printf("%s\n", b64dec);

// Heap allocation done by passing NULL to dst, don't forget to free()
    char* b64encoded = b64Encode(NULL, argv[1], strlen(argv[1]));
    printf("%s\n", b64enc);
    
    char* b64decoded = b64Decode(NULL, b64enc, strlen(b64enc));
    printf("%s\n", b64dec);
}
$ ./a.out sus
c3Vz
sus

About

base64 single header encode/decode

License:The Unlicense


Languages

Language:C 100.0%