26 lines
409 B
Go
26 lines
409 B
Go
package utils
|
|
|
|
import "encoding/base64"
|
|
|
|
// Base64
|
|
type Base64 struct {
|
|
Content []byte
|
|
}
|
|
|
|
// Encode
|
|
// 编码
|
|
// @receiver q
|
|
// @return string
|
|
func (q Base64) Encode() string {
|
|
return base64.StdEncoding.EncodeToString(q.Content)
|
|
}
|
|
|
|
// Decode
|
|
// 解码
|
|
// @receiver q
|
|
// @return string
|
|
func (q Base64) Decode() string {
|
|
res, _ := base64.StdEncoding.DecodeString(string(q.Content))
|
|
return string(res)
|
|
}
|