Go语言实现base64编码

2018-10-08 20:01:19

1点赞

  • The_Reader

    码龄5年

  • 关注

  1. package main
  2. import (
  3. 'encoding/base64'
  4. 'fmt'
  5. )
  6. func main() {
  7. var msg =[]byte('i am the reader!')
  8. encoding := base64.StdEncoding.EncodeToString(msg)
  9. fmt.Println(encoding)
  10. bytes, e := base64.StdEncoding.DecodeString(encoding)
  11. if e!=nil{
  12. fmt.Println(e)
  13. }
  14. fmt.Println(string(bytes))
  15. }

输出结果为:

aSBhbSB0aGUgcmVhZGVyIQ==
i am the reader!
是不是很简单呢!

(0)

相关推荐