The first 64 characters out of the 65-character subset are mapped to an equivalent 6-bit binary sequence ( 2 6 = 64). The Base64 encoding is described in the RFC 4648.īase64 encoding works with a 65-character subset of the US-ASCII charset. Base64 encoding size increase software#The friend’s email software will Base64-decode the above encoded textual data to restore the original binary image. IVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAARdQTFRFAAAAAAAAAAAAAAAAAQEBDAwMHBwcHx8fCwsLAwMDGRkZHh4eBAQEICAgtra2vb29pKSksLCwODg4FBQUh4eHtLS0m5ubISEh3NzciIiIERERwsLCnp6eAgICjIyMwMDAJycnDg4OBQUFEBAQ0NDQe3t7ycnJeXl5KCgo3d3daWlpCQkJDw8PzMzMmpqarKysyMjIOjo6kZGR9/f3sbGxnZ2dPDw8z8/Pfn5+FxcXjo6OsrKybm5u5ubmExMTBgYG1NTUiYmJCgoKTk5O39/fbGxs7OzsVFRUGhoa2tra9PT00dHRMTExzs7OhoaGhYWFLCwsIyMjuLi4xcXFUlJSRUVFvr6+2dnZoaGhFhYWBwcHFRUV////p5PkYgAAAAN0Uk5Tnvn4e+Nx/gAAAAFiS0dEXOrYAJcAAAAJcEhZcwAAAEgAAABIAEbJaz4AAACnSURBVBjTY2BgZEYCjAwMTMwogImBGQ0ABVhY2dg5gExOLm4esAAvH7+AoBCzsIiomDhYgEtCUkpaRlZOXkFRCSygrKIqrqauoamlqA0xQ0dXT9/A0MjYxNQMIqBsbmFpZW1ja2hnDxGwc3B0cnZxdXNnZmEBC3h4esmJefv4uvj5B4AFAoP0zINDmEPDwiMiwQJR0UrROkDFHNFREDPQnI7hOXTvAwCtbBUc7QjTawAAACV0RVh0ZGF0ZTpjcmVhdGUAMjAxOS0wMS0yMFQwNjo1NTozNiswMDowMA0Ih5IAAAAldEVYdGRhdGU6bW9kaWZ5ADIwMTktMDEtMjBUMDY6NTU6MzYrMDA6MDB8VT8uAAAARnRFWHRzb2Z0d2FyZQBJbWFnZU1hZ2ljayA2LjcuOC05IDIwMTQtMDUtMTIgUTE2IGh0dHA6Ly93d3cuaW1hZ2VtYWdpY2sub3Jn3IbtAAAAABh0RVh0VGh1bWI6OkRvY3VtZW50OjpQYWdlcwAxp/+7LwAAABh0RVh0VGh1bWI6OkltYWdlOjpoZWlnaHQAMTkyDwByhQAAABd0RVh0VGh1bWI6OkltYWdlOjpXaWR0aAAxOTLTrCEIAAAAGXRFWHRUaHVtYjo6TWltZXR5cGUAaW1hZ2UvcG5nP7JWTgAAABd0RVh0VGh1bWI6Ok1UaW1lADE1NDc5NjczMzaP/6esAAAAD3RFWHRUaHVtYjo6U2l6ZQAwQkKUoj7sAAAAVnRFWHRUaHVtYjo6VVJJAGZpbGU6Ly8vbW50bG9nL2Zhdmljb25zLzIwMTktMDEtMjAvMTVjOGNmYTk5NjBmYmJjOWUyY2NjNGI4MTY2YTI3NTQuaWNvLnBuZ0jyrXwAAAAASUVORK5CYII = For example, when you send an email containing an image to your friend, your email software Base64 encodes the image and inserts the equivalent text into the message like so -Ĭontent-Disposition: inline filename =favicon-16x16.png Although, It was later extended to support non US-ASCII text messages as well as non-text messages such as audio and images, It is still recommended to encode the data to ASCII charset for backward compatibility.īase64 encoding encodes any binary data or non-ASCII text data to printable ASCII format so that it can be safely transmitted over any communication channel. One example of such a system is Email (SMTP), which was traditionally designed to work with plain text data in the 7-bit US-ASCII character set. It represents binary data in a printable ASCII string format by translating it into a radix-64 representation.īase64 encoding is commonly used when there is a need to transmit binary data over media that do not correctly handle binary data and is designed to deal with textual data belonging to the 7-bit US-ASCII charset only. The base64 implementation shown above covers the core concept.Base64 is a binary-to-text encoding scheme. So, the space overhead is not a deal-breaker for sending files over web. The encoding size overhead is not that significant (typically around 2-5%) between the compressed original and compressed encoded files. API endpoints which have JSON payloads sometimes take the file as base64 in the JSON payload.ĭata sent over the wire, between the server and the browser is usually compressed with algorithms like gzip, brotli etc. E-Mail attachments are sent out as base64 encoded strings.īase64 is useful to send over any kind of data over the wire as a plain text string. Why is base64 used then?īase64 is used when there was a need to encode binary data so that it can be stored and transferred over mediums that primarily designed to deal with ASCII text. So, 33 % more storage is used than normal. To send three bytes of information ( cat for example) we would have to actually send out four bytes in base64 ( Y2F0). Instead of one character representing 256 (2^8) as it does in normal encoding, each character represents only 64 (2^6) states in base64.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |