Go语言实现base64编码
2018-10-08 20:01:19
1点赞
package main
import (
'encoding/base64'
'fmt'
)
func main() {
var msg =[]byte('i am the reader!')
encoding := base64.StdEncoding.EncodeToString(msg)
fmt.Println(encoding)
bytes, e := base64.StdEncoding.DecodeString(encoding)
if e!=nil{
fmt.Println(e)
}
fmt.Println(string(bytes))
}
输出结果为:
aSBhbSB0aGUgcmVhZGVyIQ==
i am the reader!
是不是很简单呢!
赞 (0)