Brother even go language training tutorials take you on the Go Case (6) Go BASE64 encoding
Source: Internet
Author: User
Brother and Go language training course system design architecture includes block language basic language Go language, blockchain back-end technology system, blockchain public chain, blockchain distributed application development, etc., and the final interview guidance Actual combat with the project. The course was carefully crafted by the Tsinghua Microsoft Google Masters team and developed over the course of half a year.
GoBase64 encoding
Go provides built-in support for base64 encoding and decoding
Packagemain
/ / This import package syntax will default to the base64 from an alias b64, so
/ / We can directly use b64 to represent this package below, save the input
Importb64"encoding/base64"
Import"fmt"
Funcmain(){
//This is the string we used to demonstrate encoding and decoding.
Data:="abc123!?$*&()'-=@~"
//Go supports base64 encoding for standard and compatible URLs.
//We use standard base64 encoding here, this
/ / Function requires a [] byte parameter, so this will
Both methods encode the original data into base64 encoding, the difference being that the standard encoding is followed by +, and the encoding of the compatible URL is followed by
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.