mirror of
https://gitee.com/johng/gf
synced 2026-07-04 21:03:13 +08:00
16 lines
295 B
Go
16 lines
295 B
Go
package gbase64
|
|
|
|
import (
|
|
"encoding/base64"
|
|
)
|
|
|
|
// base64 encode
|
|
func Encode(str string) string {
|
|
return base64.StdEncoding.EncodeToString([]byte(str))
|
|
}
|
|
|
|
// base64 decode
|
|
func Decode(str string) (string, error) {
|
|
s, e := base64.StdEncoding.DecodeString(str)
|
|
return string(s), e
|
|
} |