![]() ![]() ![]() Java 8 introduced us to a new class - Base64. All emails are encoded before the applications send them. Email servers, for example, expect textual data. Also, many servers don't expect raw binary data. This data must be processed differently, depending on what it's supposed to represent. It can be part of an image, it can be a part of an audio file or it can be a command that deletes half of your hard drive. A sequence such as 0010110 can mean many things. Why use Base64 Encoding?Ĭomputers work with 0s and 1s, so why bother converting this into another format? This means that it takes ~33% more space to store a Base64 encoded string as opposed to the original string. Note: 6 input characters are encoded into 8 characters in the end. In the end, we're left with the string QUJDMTIz - the Base64 representation of ABC123. Finally, using the Base64 chart, convert each decimal number into a Base64 character:.Get the decimal values of these binary chunks: If it's impossible to break it up into chunks of six, we have to pad the sequence. Convert the decimal value of each character into an 8-bit binary:.Take ASCII values of input characters separately:.There are five steps we take during this process: Manual Encodingįor example, let's say we have a string - ABC123 that we'd like to encode in Base64. Let's go ahead and manually encode a simple string to get a good idea of how the process works. Though, this is impractical due to difficulties in the encoding/decoding process. You could go higher than this and have each character represent 8 bits. So 64 characters of Base64 can be written as:Įach character is represented in 6 bits. Note: There is also a 65th character ( =), which serves a special meaning and it's called a padding character.Īs usual, when it comes to computers, numbers are represented in powers of 2. In Base64, as the name suggests, there are 64 characters used to encode binary data. While it does "obscure" the data to a degree, it's not a secure format by any means since reversing the encoding is trivial. What Base64 isn't is an encryption algorithm. It's very useful for storing image/audio information as strings of information. It's represented as printable ASCII characters where each Base64 character contains 6 bits of binary information. What is Base64?īase64 is a binary-to-text encoding scheme. Decoding is the reverse process of encoding - turning the encoded data back to the original format.Įncoding is all around us and computers heavily rely on different encoding formats to deliver and transfer information.įrom the latest cat image in your feed to the voice message you listened to over a messaging app - all of these were encoded on the sender-side, delivered to you, and decoded on the recipient-side.Įncoding makes sure that data remains intact and efficient for transport. The process of converting data by applying some techniques/rules into a new format is called encoding. ![]()
0 Comments
Leave a Reply. |