Base64 Encode
With the Base64 Encode tool, you can encrypt the text you enter with the Base64 method. If you wish, you can decode the encrypted Base64 code with the Base64 Decode tool.
What is Base64 encode?
Base64 Encode is an encoding scheme that allows binary data to be transported on environments that use only some restricted character encodings (environments where not all character codes can be used, such as xml, html, script, instant messaging applications). The number of characters in this scheme is 64, and the number 64 in the word Base64 comes from here.
Why Use Base64 encode?
The need for Base64 encoding stems from problems that arise when media is transmitted in raw binary format to text-based systems. Because text-based systems (such as e-mail) interpret binary data as a wide range of characters, including special command characters, most of the binary data transmitted to the transfer medium is misinterpreted by these systems and is lost or corrupted in the transmission process.
One method of encoding such binary data in a way that avoids such transmission problems is to send them as plain ASCII text in Base64 encoded format. This is one of the techniques used by the MIME standard to send data other than plain text. Many programming languages, such as PHP and Javascript, include Base64 encoding and decoding functions to interpret data transmitted using Base64 encoding.
Base64 encode logic
In Base64 encoding, 3 * 8 bits = 24 bits of data consisting of 3 bytes are divided into 4 groups of 6 bits. The characters corresponding to the decimal values between [0-64] of these 4 6-bit groups are matched from the Base64 table to encode. The number of characters obtained as a result of Base64 encoding must be a multiple of 4. Encoded data that is not a multiple of 4 is not valid Base64 data. When encoding with the Base64 algorithm, when the encoding is complete, if the length of the data is not a multiple of 4, the "=" (equal) character is added to the end of the encoding until it is a multiple of 4. For example, if we have 10-character Base64 encoded data as a result of the encoding, two "==" should be added to the end.
Base64 encode example
For example, take the three ASCII numbers 155, 162 and 233. These three numbers form a binary stream of 100110111010001011101001. A binary file, such as an image, contains a binary stream that works for tens or hundreds of thousands of zeros and ones. A Base64 encoder starts by splitting the binary stream into groups of six characters: 100110 111010 001011 101001. Each of these groupings is translated into numbers 38, 58, 11, and 41. A six-character binary stream is converted between binary (or basic). 2) to decimal (base-10) characters by squaring each value represented by 1 in the binary array by the positional square. Starting from the right and moving to the left and starting at zero, the values in the binary stream represent 2^0, then 2^1, then 2^2, then 2^3, then 2^4, then 2^5.
Here is another way to look at it. Starting from the left, each position is worth 1, 2, 4, 8, 16 and 32. If the slot has a binary number 1, you add that value; if the slot has 0, you are missing. Binary array 100110 turns 38: 0 * 2 ^ 01 + 1 * 2 ^ 1 + 1 * 2 ^ 2 + 0 * 2 ^ 3 + 0 * 2 ^ 4 + 1 * 2 ^ 5 = 0 + 2 decimal + 4 + 0 + 0 + 32. Base64 encoding takes this binary string and divides it into 6-bit values 38, 58, 11 and 41. Finally, these numbers are converted to ASCII characters using the Base64 encoding table.