首页 > 代码库 > WebSafeBase64Decode

WebSafeBase64Decode

 

WebSafeBase64Decode  golang  (adapter zplay doubleclick )
func base64url_decode(s string) ([]byte, error) {
    base64Str := strings.Map(func(r rune) rune {
        switch r {
        case -:
            return +
        case _:
            return /
        }

        return r
    }, s)

    if pad := len(base64Str) % 4; pad > 0 {
        base64Str += strings.Repeat("=", 4-pad)
    }

    return base64.StdEncoding.DecodeString(base64Str)
}

 

WebSafeBase64Decode