MCPcopy Create free account
hub / github.com/Preloading/TwitterAPIBridge / Base64URLDecode

Function Base64URLDecode

cryption/authcrypt.go:128–146  ·  view source on GitHub ↗

Base64URLDecode decodes the given URL-safe string using base64 and returns the result as a string

(input string)

Source from the content-addressed store, hash-verified

126
127// Base64URLDecode decodes the given URL-safe string using base64 and returns the result as a string
128func Base64URLDecode(input string) (string, error) {
129 input = strings.ReplaceAll(input, "-", "+")
130 input = strings.ReplaceAll(input, "_", "/")
131
132 // Add padding if necessary
133 switch len(input) % 4 {
134 case 2:
135 input += "=="
136 case 3:
137 input += "="
138 }
139
140 decoded, err := base64.StdEncoding.DecodeString(input)
141 if err != nil {
142 return "", err
143 }
144
145 return string(decoded), nil
146}
147
148type PasswordData struct {
149 Hash string

Callers 3

GetAuthFromReqFunction · 0.92
CheckTokenTypeFunction · 0.92
ConvertV1TokenToV2Function · 0.92

Calls

no outgoing calls

Tested by

no test coverage detected