base64 package main import ( "encoding/base64" "fmt" ) /*通用编码表,编码解码*/ func system() { s := "heal the world, make it a better place" fmt.Println("原始数据", s) //编码 s64_std := base64.StdEncoding.EncodeToString([]byte(s)) fmt.Println("编码", s64_std) //解码 decodeBytes, err := base64.StdEncoding.DecodeString(s64_std) if err != nil { fmt.Println(err) } fmt.Println("解码", string(decodeBytes)) } /* 自定义编码表,编码,解码(自定义码表 可随意变换字母排列顺序,然后会自动生成解密表) Base64只能算是一个编码算法 即使你自己自定义字符集设计一种类Base64的编码方式用于数据加密,在多数场景下也较容易破解 */ func self() { s := "heal the world, make it a better place" fmt.Println("原始数据", s) encodeStd := "abcdefghijkABCDEFGHIJ345QRSTUVWXYZlmnopqrstuKLMNOPvwxyz0126789+/" s64 := base64.NewEncoding(encodeStd).EncodeToString([]byte(s)) fmt.Println("s