AminetAminet
Search:
84450 packages online
About
Recent
Browse
Search
Upload
Setup
Services

dev/c/b64.lha

Mirror:Random
Showing:m68k-amigaosppc-amigaosppc-morphosi386-arosi386-amithlonppc-warpupppc-powerupgeneric
No screenshot available
Short:Base64 encode/decode lib written in C
Author:Joseph Werle
Uploader:Carsten Larsen (carsten larsen mail com)
Type:dev/c
Version:1.0
Architecture:generic; m68k-amigaos
URL:https://github.com/littlstar/b64.c.git
Date:2020-04-30
Download:http://aminet.net/dev/c/b64.lha - View contents
Readme:http://aminet.net/dev/c/b64.readme
Downloads:657

Usage

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

    int
    main (void) {
    unsigned char *str = "brian the monkey and bradley the kinkajou are
friends";
    char *enc = b64_encode(str, strlen(str));

    printf("%s\n", enc); //
YnJpYW4gdGhlIG1vbmtleSBhbmQgYnJhZGxleSB0aGUga2lua2Fqb3UgYXJlIGZyaWVuZHM=

    char *dec = b64_decode(enc, strlen(enc));

    printf("%s\n", dec); // brian the monkey and bradley the kinkajou are
friends
    free(enc);
    free(dec);
    return 0;
    }

Installation

    Copy encode.c and/or decode.c to you source code tree.

API

Base64 index table

    static const char b64_table[] = {
    'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
    'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
    'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',
    'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f',
    'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
    'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
    'w', 'x', 'y', 'z', '0', '1', '2', '3',
    '4', '5', '6', '7', '8', '9', '+', '/'
    };

char * b64_encode (const unsigned char *, size_t);

    Encode unsigned char * source with size_t size. Returns a char * base64
    encoded string.

unsigned char * b64_decode (const char *, size_t);

    Decode char * source with size_t size. Returns a unsigned char * base64
    decoded string.

License

    MIT


Contents of dev/c/b64.lha
 PERMSSN    UID  GID    PACKED    SIZE  RATIO METHOD CRC     STAMP          NAME
---------- ----------- ------- ------- ------ ---------- ------------ -------------
[Amiga]                    540    1367  39.5% -lh5- 7533 Apr 29 12:30 b64/b64.h
[Amiga]                  15772   28044  56.2% -lh5- af4d Apr 29 12:30 b64/base64
[Amiga]                   2172    6682  32.5% -lh5- 1bef Apr 29 12:30 b64/base64.c
[Amiga]                    753    1594  47.2% -lh5- 3e0f Apr 29 12:30 b64/base64.readme
[Amiga]                   1005    2914  34.5% -lh5- 1c1d Apr 29 12:30 b64/decode.c
[Amiga]                    843    2129  39.6% -lh5- 2a59 Apr 29 12:30 b64/encode.c
[Amiga]                    661    1129  58.5% -lh5- f766 Apr 29 12:30 b64/LICENSE
[Amiga]                    265     460  57.6% -lh5- d0a6 Apr 29 12:30 b64/Makefile
[Amiga]                  15969   28988  55.1% -lh5- aca7 Apr 29 12:30 b64/test
[Amiga]                    829    1943  42.7% -lh5- 5edf Apr 29 12:30 b64/test.c
---------- ----------- ------- ------- ------ ---------- ------------ -------------
 Total        10 files   38809   75250  51.6%            Apr 30 22:18

Aminet © 1992-2024 Urban Müller and the Aminet team. Aminet contact address: <aminetaminet net>