1. 字串的base64编码
func (enc *Encoding) EncodeToString(src []byte) string
import (
"encoding/base64"
"fmt"
)
func HelloXD() {
myString := "臣本布衣 躬耕于陇上"
res := base64.StdEncoding.EncodeToString([]byte(myString))
fmt.Println(res)
}
6Iej5pys5biD6KGjIOi6rOiAleS6jumZh+S4ig==
2. 字串的base64解码
func (enc *Encoding) DecodeString(s string) ([]byte, error)
func HelloXD(){
s,_ := base64.StdEncoding.DecodeString("6Iej5pys5biD6KGjIOi6rOiAleS6jumZh+S4ig==")
fmt.Printf("base64解码结果为:%s",string(s))
}
base64解码结果为:臣本布衣 躬耕于陇上