VC++ explains the principle of Base64 encoding and decoding in detail and the implementation of Base64 encoding and decoding interface (with source code)

       Base64 encoding has been widely used in various applications. These software are enjoying the convenience brought by Base64 encoding, but how much do you know about the concepts and principles of Base64 encoding? This article will talk about the Base64 encoding related content.

1. The practical problems that Base64 encoding helps us solve

       When we use libjingle (client) and XMPP server to implement the IM chat function, during the test, we found that when the information sent contains some special characters (unrecognized characters), the XMPP server will forcibly disconnect the client. It was strange at first, why the XMPP server disconnected the libjingle client after sending a few random messages. After investigation, it was found that the data exchanged between libjingle and the XMPP server was in XML format, because the chat message string contained characters that were not recognized by XML. The terminal is disconnected. In order to solve this problem, first base64 encode the chat information string, convert it into identifiable characters, and then write it into the XML node, so as to ensure that no unrecognizable characters appear in the XML data, and the XMPP server will not Then forcibly disconnect the libjingle client.

2. Principle of Base64 encoding and decoding

       

Guess you like

Origin blog.csdn.net/chenlycly/article/details/124106136