1
0
mirror of https://github.com/nitezs/sub2clash.git synced 2024-12-24 13:04:41 -05:00
sub2clash/parser/base64.go

19 lines
316 B
Go
Raw Normal View History

2023-09-12 06:40:24 -04:00
package parser
import (
"encoding/base64"
"strings"
2023-09-12 06:40:24 -04:00
)
func DecodeBase64(s string) (string, error) {
s = strings.TrimSpace(s)
if len(s)%4 != 0 {
s += strings.Repeat("=", 4-len(s)%4)
}
2023-09-12 06:40:24 -04:00
decodeStr, err := base64.StdEncoding.DecodeString(s)
if err != nil {
return "", err
}
return string(decodeStr), nil
}