This is a created article in which the information may have evolved or changed.
First explain the following what is Base64 (from Baidu Encyclopedia):
Base64 is one of the most common encoding methods for transmitting 8Bit bytes of code on the network, and you can view rfc2045~rfc2049, which has a detailed specification of MIME. BASE64 encoding can be used to pass longer identity information in an HTTP environment. For example, in the Java Persistence System hibernate, Base64 is used to encode a long unique identifier (typically 128-bit uuid) as a string that is used as a parameter in an HTTP form and an HTTP GET URL. In other applications, it is often necessary to encode binary data as appropriate in the form of URLs (including hidden form fields). At this time, the use of BASE64 encoding is not readable, that is, the encoded data will not be directly visible to the naked eye.
There are base64 libraries in the Golang that can be implemented, and I try to implement the cryptographic decryption function.
At the same time I think they can also be used for the transmission of chat messages.
Func Decode (Raw []byte) []byte {var buf bytes. bufferdecoded: = Make ([]byte, 215) buf. Write (RAW) Decoder: = base64. Newdecoder (base64. Stdencoding, &BUF) decoder. Read (decoded) return Decoded}func Encode (Raw []byte) []byte {var encoded bytes. Bufferencoder: = base64. Newencoder (base64. Stdencoding, &encoded) encoder. Write (RAW) encoder. Close () return encoded. Bytes ()}