Base64URLDecode decodes the given URL-safe string using base64 and returns the result as a string
(input string)
| 126 | |
| 127 | // Base64URLDecode decodes the given URL-safe string using base64 and returns the result as a string |
| 128 | func 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 | |
| 148 | type PasswordData struct { |
| 149 | Hash string |
no outgoing calls
no test coverage detected