Blockchain circle

One stop hot information platform

About us:

Blockchain circle provides the latest information about blockchain, digital currency, digital wallet, exchange, metauniverse, bitcoin, Ethereum, contract, financial management and so on, and always pays attention to the latest market...

What is the principle of blockchain Base64 coding

Time : 28/11/2021 Author : 0wqz3a Click : + -
        This article mainly explains "what is the principle of blockchain Base64 coding", and interested friends may come to have a look. The method introduced in this paper is simple, fast and practical. Let's take you to learn "what is the principle of blockchain Base64 coding"!. At present, Base64 has become one of the common coding methods for transmitting 8bit byte code on the network. In the payment system, the message interaction between the systems needs to use Base64 to transcode the plaintext, then sign or encrypt, and then transmit (or re Base64). So, what role does Base64 play?.
 
        A situation often encountered in the process of parameter transmission: it is OK to use all English, but when it comes to Chinese, there will be confusion. Similarly, the characters transmitted on the network are not all printable characters, such as binary files and pictures. Base64 is to solve this problem. It is a method to represent binary data based on 64 printable characters. At the beginning of e-mail, only English could be transmitted, but later, with the increase of users, users of Chinese, Japanese and other characters also had demand, but these characters could not be effectively processed by the server or gateway, so Base64 came into the market.
 
        Subsequently, Base64 is also used in URLs, cookies, and a small number of binary files transmitted by web pages. The above is the index table of Base64. The characters are A-Z, A-Z, 0-9, +, and / 64 printable characters. This is the standard Base64 protocol. In daily use, we can also see that "=" or "= =" sign appears in Base64 encoding results, and "=" here appears as a padding character, which will be described later. The characters in the base64 character table can be represented by 6 bits. Now, 2 zeros are added in front of the table to 8 bits, which will cause some waste.
 
        Therefore, the base64 encoded text is about one-third larger than the original text. Why use a group of 3 bytes? Because the minimum common multiple of 6 and 8 is 24, the three bytes have exactly 24 binary bits, and every 6 bits is a group, which can be divided into 4 groups. Step 1: the ASCII code values of "m", "a" and "n" are 77 and 97110 respectively, and the corresponding binary values are 01001101, 0110001 and 01101110. As shown in the second and third lines of the figure, a 24 bit binary string is thus formed. Step 3: fill two zeros in front of each group above and expand them into 32 binary bits, which will become four bytes: 00010011, 00010110, 00000101, 00101110.
 
        The corresponding values (Base64 coding index) are: 19, 22, 5, 46. Step 4: search the base64 coding table with the above values, corresponding to t, W, F and u respectively. Therefore, "man" becomes: twfu after Base64 encoding. Two bytes: two bytes have 16 binary bits in total and are still grouped according to the rules. At this time, there are 16 binary bits in total, and every 6 bits are in a group, then the third group is missing 2 bits, and is filled with 0 to obtain three Base64 codes. If the fourth group has no data at all, it is filled with "=". Therefore, "BC" in the above figure is converted to "qkm =";.
 
        One byte: a byte has 8 bits in total and is still grouped according to the rules. At this time, there are 8 binary bits in total, and every 6 bits are in a group, then the second group lacks 4 bits, and is filled with 0 to obtain two Base64 codes. However, the last two groups have no corresponding data, and are filled with "=". Therefore, "a" in the above figure is converted to "QQ = =";. Most encoding is the process of converting from string to binary, while Base64 encoding is the process of converting from binary to string. Contrary to the rule, yes,. Base64 encoding is mainly used in the fields of transmission, storage and representation of binary, which can not be regarded as encryption, but can not directly see plaintext.
 
        Encryption can also be performed by scrambling the base64 encoding. There are many kinds of Chinese codes (such as UTF-8, GB2312, GBK, etc.), and the base64 coding results corresponding to different codes are different. As we have seen above, Base64 represents characters with 6 bits (the sixth power of 2 is 64), so it is called Base64. Similarly, base32 uses 5 bits and base16 uses 4 bits. You can follow the above steps to evolve. At this point, I believe you have a deeper understanding of "what is the principle of blockchain Base64 coding", and you may as well have a practical operation! This is the Yisu cloud website. For more related content, please enter the relevant channels for inquiry. Follow us and continue to learn!.
 
        
Previous:Guangxi blockchain industry development white paper (2022) with download
Next:No more

Related articles:



© 2005-2032 | Blockchain Circle & & All Rights Reserved    Sitemap1 Sitemap2 If there is infringement, please contact us at: