chat-backend/util/base64.go

26 lines
408 B
Go

package util
import "encoding/base64"
// Base64
type Base64 struct {
Content []byte
}
// Encode
// 编码
// @receiver b
// @return string
func (b Base64) Encode() string {
return base64.StdEncoding.EncodeToString(b.Content)
}
// Decode
// 解码
// @receiver b
// @return string
func (b Base64) Decode() string {
res, _ := base64.StdEncoding.DecodeString(string(b.Content))
return string(res)
}