{"id":16556201,"url":"https://github.com/elzoughby/base64","last_synced_at":"2025-03-21T10:32:21.571Z","repository":{"id":59375288,"uuid":"98089809","full_name":"elzoughby/Base64","owner":"elzoughby","description":"C library to encode and decode strings with base64 format","archived":false,"fork":false,"pushed_at":"2018-05-09T23:28:19.000Z","size":10,"stargazers_count":71,"open_issues_count":4,"forks_count":25,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-18T00:38:30.650Z","etag":null,"topics":["ascii","base64","c","decode-strings","decoding","encode-strings","encoding","string"],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/elzoughby.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-07-23T10:14:30.000Z","updated_at":"2025-03-09T20:02:18.000Z","dependencies_parsed_at":"2022-09-16T05:00:27.827Z","dependency_job_id":null,"html_url":"https://github.com/elzoughby/Base64","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elzoughby%2FBase64","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elzoughby%2FBase64/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elzoughby%2FBase64/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elzoughby%2FBase64/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/elzoughby","download_url":"https://codeload.github.com/elzoughby/Base64/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244778027,"owners_count":20508838,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ascii","base64","c","decode-strings","decoding","encode-strings","encoding","string"],"created_at":"2024-10-11T20:03:46.941Z","updated_at":"2025-03-21T10:32:21.272Z","avatar_url":"https://github.com/elzoughby.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Base64\n\n**[Base64](https://en.wikipedia.org/wiki/Base64)** is a group of similar [binary-to-text encoding](https://en.wikipedia.org/wiki/Binary-to-text_encoding) schemes that represent [binary data](https://en.wikipedia.org/wiki/Binary_data) in an [ASCII](https://en.wikipedia.org/wiki/ASCII) string format by translating it into a [radix](https://en.wikipedia.org/wiki/Radix)-64 representation. The term *Base64* originates from a specific [MIME content transfer encoding](https://en.wikipedia.org/wiki/MIME#Content-Transfer-Encoding). Each base64 digit represents exactly 6 bits of data.\n\nThe particular set of 64 characters chosen to represent the 64 place-values for the base varies between implementations. The general strategy is to choose 64 characters that are both members of a subset common to most encodings, and also [printable](https://en.wikipedia.org/wiki/Graphic_character). This combination leaves the data unlikely to be modified in transit through information systems, such as email, that were traditionally not [8-bit clean](https://en.wikipedia.org/wiki/8-bit_clean).[[1\\]](https://en.wikipedia.org/wiki/Base64#cite_note-autogenerated2006-1) For example, MIME's Base64 implementation uses `A`–`Z`, `a`–`z`, and `0`–`9` for the first 62 values.\n\n#### Example\n\nA quote from [Thomas Hobbes](https://en.wikipedia.org/wiki/Thomas_Hobbes)' *Leviathan*:\n\n\u003e Man is distinguished, not only by his reason, but by this singular passion from other animals, which is a lust of the mind, that by a perseverance of delight in the continued and indefatigable generation of knowledge, exceeds the short vehemence of any carnal pleasure.\n\nis represented as a byte sequence of 8-bit-padded [ASCII](https://en.wikipedia.org/wiki/ASCII) characters encoded in [MIME](https://en.wikipedia.org/wiki/MIME)'s Base64 scheme as follows:\n\n\u003e TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb24sIGJ1dCBieSB0aGlzIHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlciBhbmltYWxzLCB3aGljaCBpcyBhIGx1c3Qgb2YgdGhlIG1pbmQsIHRoYXQgYnkgYSBwZXJzZXZlcmFuY2Ugb2YgZGVsaWdodCBpbiB0aGUgY29udGludWVkIGFuZCBpbmRlZmF0aWdhYmxlIGdlbmVyYXRpb24gb2Yga25vd2xlZGdlLCBleGNlZWRzIHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4K\n\nIn the above quote, the encoded value of *Man* is *TWFu*. Encoded in ASCII, the characters *M*, *a*, and *n* are stored as the bytes `77`, `97`, and `110`, which are the 8-bit binary values `01001101`, `01100001`, and `01101110`. These three values are joined together into a 24-bit string, producing `010011010110000101101110`. Groups of 6 bits (6 bits have a maximum of 26 = 64 different binary values) are [converted into individual numbers](https://en.wikipedia.org/wiki/Binary_number#Counting_in_binary) from left to right (in this case, there are four numbers in a 24-bit string), which are then converted into their corresponding Base64 character values.\n\nThe Base64 index table: [[2]](https://en.wikipedia.org/wiki/Base64)\n\n| Value | Char | Value | Char | Value | Char | Value | Char |\n| ----- | ---- | ----- | ---- | ----- | ---- | ----- | ---- |\n| 0     | `A`  | 16    | `Q`  | 32    | `g`  | 48    | `w`  |\n| 1     | `B`  | 17    | `R`  | 33    | `h`  | 49    | `x`  |\n| 2     | `C`  | 18    | `S`  | 34    | `i`  | 50    | `y`  |\n| 3     | `D`  | 19    | `T`  | 35    | `j`  | 51    | `z`  |\n| 4     | `E`  | 20    | `U`  | 36    | `k`  | 52    | `0`  |\n| 5     | `F`  | 21    | `V`  | 37    | `l`  | 53    | `1`  |\n| 6     | `G`  | 22    | `W`  | 38    | `m`  | 54    | `2`  |\n| 7     | `H`  | 23    | `X`  | 39    | `n`  | 55    | `3`  |\n| 8     | `I`  | 24    | `Y`  | 40    | `o`  | 56    | `4`  |\n| 9     | `J`  | 25    | `Z`  | 41    | `p`  | 57    | `5`  |\n| 10    | `K`  | 26    | `a`  | 42    | `q`  | 58    | `6`  |\n| 11    | `L`  | 27    | `b`  | 43    | `r`  | 59    | `7`  |\n| 12    | `M`  | 28    | `c`  | 44    | `s`  | 60    | `8`  |\n| 13    | `N`  | 29    | `d`  | 45    | `t`  | 61    | `9`  |\n| 14    | `O`  | 30    | `e`  | 46    | `u`  | 62    | `+`  |\n| 15    | `P`  | 31    | `f`  | 47    | `v`  | 63    | `/`  |\n\n## Base64 Library\n\nThis is a C library to encode ASCII string to base64 format and decode base64 string to ASCII.\n\n### Functions\n\n- **base64_encode**\n\n  ```c\n  char* base64_encode(char* plain);\n  /***********************************************\n  Encodes ASCCI string into base64 format string\n  @param plain: ASCII string to be encoded\n  @return encoded base64 format string\n  ***********************************************/\n  ```\n\n- **base64_decode**\n\n  ```c\n  char* base64_decode(char* cipher);\n  /***********************************************\n  decodes base64 format string into ASCCI string\n  @param plain encoded base64 format string\n  @return ASCII string to be encoded\n  ***********************************************/\n  ```\n\n## Base64 App Example\n\nAn Example program to demonstrate the Base64 library by  giving the inputs through command line arguments and getting the output on the screen or written in a file.\n\n- **Usage** `base64 (encode | decode) \u003csource\u003e [\u003cdestination\u003e]`\n- **Options**\n  - *`encode`*  -  Convert ASCII string into Base64 format\n  - *`decode`*  -  Convert Base64 format into ASCII string\n- **Arguments**\n  - *`\u003csource\u003e`*  -  String or path/to/file to be converted\n  - *`\u003cdestination\u003e`*  -  Path/to/converted/file\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felzoughby%2Fbase64","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Felzoughby%2Fbase64","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felzoughby%2Fbase64/lists"}