Updates on Sundays
#include <stdio.h> #include <stdint.h> #include <stdlib.h> #include <string.h> static char encoding_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', '+', '/'}; static char *decoding_table = NULL; static int mod_table[] = {0, 2, 1}; void build_decoding_table() { decoding_table = malloc(256); for (int i = 0; i < 64; i++) decoding_table[(unsigned char) encoding_table[i]] = i; } void base64_cleanup() { free(decoding_table); } unsigned char *base64_decode(const char *data, size_t input_length, size_t *output_length) { if (decoding_table == NULL) build_decoding_table(); if (input_length % 4 != 0) return NULL; *output_length = input_length / 4 * 3; if (data[input_length - 1] == '=') (*output_length)--; if (data[input_length - 2] == '=') (*output_length)--; unsigned char *decoded_data = malloc(*output_length); if (decoded_data == NULL) return NULL; for (int i = 0, j = 0; i < input_length;) { uint32_t sextet_a = data[i] == '=' ? 0 & i++ : decoding_table[data[i++]]; uint32_t sextet_b = data[i] == '=' ? 0 & i++ : decoding_table[data[i++]]; uint32_t sextet_c = data[i] == '=' ? 0 & i++ : decoding_table[data[i++]]; uint32_t sextet_d = data[i] == '=' ? 0 & i++ : decoding_table[data[i++]]; uint32_t triple = (sextet_a << 3 * 6) + (sextet_b << 2 * 6) + (sextet_c << 1 * 6) + (sextet_d << 0 * 6); if (j < *output_length) decoded_data[j++] = (triple >> 2 * 8) & 0xFF; if (j < *output_length) decoded_data[j++] = (triple >> 1 * 8) & 0xFF; if (j < *output_length) decoded_data[j++] = (triple >> 0 * 8) & 0xFF; } return decoded_data; } int main() { char *encodedString = malloc(8192); strcat(encodedString, "VGFrZSB0aGUgcmVkIHBsYW5ldCEgVTJGc2RHVmtYMThRaENWSkc1YmZ1SXhoekt0c1RHbE0rTGpmZXZvRXhEYUVXK3VNeVBrYzRLQ0FVcktRNGNNY1ZaVkVsaFFCWmRHWlpqQkZPa08wRHJGZzE0RzJxN2R6WW5adkRnRTZXTzFIWTgyRUZuRkJVM"); strcat(encodedString, "3JlNyt3dUVvcDV6NnpnMHpEOU93RWVEVFRZWExvcW1ZRUY5N25NejZ2SGgyOWE2cXJ2RzIvTG5ORTdqektaQnozZHhXb2pjSGx3c3JqWE1CSzRYNm1CSHpoSGYwOWFaNmhkMFNWVFRmUkNIelRCaVU5TzNEcWwrTU1SWEVWSXNiWjVpcmlUR1NVT"); strcat(encodedString, "TV5b0F2akZWWFlJMVdtQVVSckpYdmNNNEtWaXJvcks2QmtBejVXMDB4b1BaTW05SThUeHVxdjFEOUFYaWJOeXBINWZldVludHFqRlFKbVZheDE0ZXVyV1FjOU0wMGw4cEFtbE5aK251NVoyM0JSaEI5ZnFFWmtveDFwdEU1UndsbnBhZzFBY1hrVStUeUxL"); strcat(encodedString, "TnVvTFRqdUhJeDFaa2xVNnlnZ2tEK014VGpyeXpSZlNDbjVrcXVMWXJvd3RiRFlqNFlKR1VVemJRWUhOSS91NVVXQVhtR1pZY2NleWlOQjYxQjd2VGQrOTVDQlZOYXNwbnhFSFdTN1RKQXVqT2ZYbnNhRzJVMC8zd0taTFdGNW9ub3RkRmhQR3VlWkZtbk"); strcat(encodedString, "1tSmRNOGdPZXk2cGVqaVRBdkpvT3FpNXVHTUtCa0MreUR0blpRZ2hyTkRqa2RNL3ZKYXE1VWhTOUpXTzBmMzFqeXpvY3ZnQWJVbWlhNTFuYnpxMjFQOUszYi85RmNQY09WbUltMTJyN1lxbG1pKzR4cnA4TEhRaHJWemQ0R2lSNll0ZThCM2FXSzFBV2hW"); strcat(encodedString, "Z0F6MXk5aGo2dkt5d2JzR1VQUDJIRGhsbElEdzFtanAzZnY5T2JPS3d3UkNBZUxyODB0bXpnbFVTYnpENnhVWmkyWitTT2Jtdk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WVZHMVdwZEd6MTJBTFdKK0hGUk0wd0tkK0k2REljck5JK1laRDcrVWtWSVZ"); strcat(encodedString, "iZHFUUEUxYXdrRWZwdGRxbkNpcXV4MUJERHI0WWpuaEt6ajRMY3dRRnJxVnMxV0ludWNEckRNQm9QQ00reGtWN21nRk1zUEIwV2tVTWFIK1p0M3c5OWFqcVQyU2VqSU1LUjVQUWpIc0RySEI1eVJqTzlLUXptL3NwVHZvd2wyRU5Lc0dLNXYxcUIrQVl4cUdkeUx"); strcat(encodedString, "xS0hyRkFCa0lzdWVTWWRFaXd2RFVMZTZqVE1EY3ljVFJib1p3OS92MXUzMm9PQVpETjQzTFQ5S21xR3ZOSkM1VGZWZmhCaW1sMGh6MFdyZ05RY3dsaUFpNmFZSlduRWhXZGRjY0g0YmoyQ2pLVjBMTHJBREJQTllHbktjUlk0WDF4Njd2cHRudzVZaXFNLz"); strcat(encodedString, "ZFMXVXTUNYbXJESGhTTFhNTXhXVk41RFRqdHQxMG9SMEwybzZhbUFLMWVPdm5iNDhpc3NPQ1VVcWZCRVVHVmhzWjdJb01iZjBReWFnanpFWjFjZis5djZhNTU0Vy9NbGxVVEZnUDdsK3dmT2ZmSVB3RjFVSkl3a0ZMeUQ5eUpib3B4dk9sK2xvTEtRQ"); strcat(encodedString, "2J5Zm1kMmZZbU9iY2l6cms1SlA0T09taE5wTUYzVkZkYXUrVkhzcGhJNDFtTThyblc3cDdYdkxtZkZ6UU9JME5GQkdTZENGc2xDbml1SGdLb21jS2t1dmtGK1hEdlljamZXWGltOFFKb0loRFVWa0U5MVhNOHFzV3dVc2lNeVlQUlZZdzl0emQ0MVllc2lZNjk1MXJ2a"); strcat(encodedString, "2RrUkovckIrbEtBUkgwbkx3MFE5TS9PWld0L3BxMFdqVWdVSHovb1hScDR3NUpBcHBXTEx3ZGdIL1V6UEI0ckpCd1VxM2FnNWJ1QnZFQWgwQXVxVU4zTUljeU84WjVaSDltSERtYkFCV3diSGhSTGhHRWY1RVJiR0pqZjk2eUF1ZFhXMEdwSURsYlQvNVlkWmt"); strcat(encodedString, "MK1IxOWR4aXJOV0ZJNFlZZitmZ242ZFJWdlpxM1NwY1N3ZkVYOStSbDBOcWN4RzV2Y0dsYkxkSGNXWitaTFNlV1FVZmtaYUpFY0ZZMGl6RFhoZFZibGlReTJ1L2EycWYwWHRGRlZLZU5CLzRUWGw0U09JbElWdmhCTkF3YkpEZWRrZERLTFd1dllEeHdQOXFE"); strcat(encodedString, "NjRhTTh4UzhjdXVLcGdmUFd1Y2NXNHVxdHNIQk12eFYyTVVoQ0M5QUtmTWtBYlh2V045NHBCYlRrQ2lhSURCYXVZVVBaV0d6N00vanNjcEFvdG1OSzRLdmluaVlma3htT0UvV3JPTys3TnFkWmxTYXhNdDYwRy9xdWwvalpIbllGTFBBdytPWDRFaG5FbnRPUXo3"); strcat(encodedString, "V0k4LytyWWRTNjZ3bVAzVGxoTG5jNlkrWW5YNm1hK281N3RVY1hBUXZMT3RnYnNkdWxiRXhqQ3FGRWFBbWozYnRXUDBUVkdhelhZT0FDdFZqalNLRGIrMCthK04rdllkM1BLS2V0cnZrZTdrVmd0YjFsKzR5aGtSa3Z0U2hXV2ZPblF4MmNxQ2tEZlRQL2ZlME"); strcat(encodedString, "hBMCsyMElsc2Y5OFI0Ukt1eTlENHN5YjRpUGZGY2NrVllNS0pYblVQRzJ1QWtUY0l2azQ1UVc5Qkx6NUVTYmZ3QlJRb2c3M21yRWd2ZjZqVkRuMnczUEcwcStYZDJJUEFJdWlFT21FQzU2ZHhMWFhKWVBISERndmtXOFdicVNCd2QrTTZHdjNDTFcreHFWRkovMTh"); strcat(encodedString, "yOTJTTGtyYk41QnVsNmozWW1nTStrWkNLb2dTUjdjOVJjRGRrUVNFeFhFMmVaZklOaGJXOGg2bE5icWl4R3FIVVVWOFR4ZGFFY0FGTXg5aVFEUDZLMCtJU09mOG91Q2VPUC9WTlpveklKK1BzSzZzb2NSZVRrSm15S3VwM1pQeW1jTzdaS2h5YWE4aURYQm");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ZoM1lwQThISFA1azdNcEE9PQ=="); size_t inputLength = strlen(encodedString); size_t outputLength = 0; char *decodedString = base64_decode(encodedString, inputLength, &outputLength); printf("%.*s\n", outputLength, decodedString); free(decodedString);}