base64.go 346 B

123456789101112131415161718
  1. package utils
  2. import (
  3. "encoding/base64"
  4. )
  5. func Base64Encode(src []byte) []byte {
  6. return []byte(base64.StdEncoding.EncodeToString(src))
  7. }
  8. func Base64Decode(src []byte) ([]byte, error) {
  9. return base64.StdEncoding.DecodeString(string(src))
  10. }
  11. func Base64DecodeStr(src string) ([]byte, error) {
  12. return base64.StdEncoding.DecodeString(src)
  13. }