// decodeBase64Credentials decodes a base64-encoded username:password pair
// such as those used in HTTP basic authentication.
decodeBase64Credentials decodes a base64-encoded username:password pair
such as those used in HTTP basic authentication.
// decodeBase64Credentials decodes a base64 - encoded username : password pair // such as those used in HTTP basic authentication .
func decodeBase64Credentials(auth string) (user, pass string, ok bool) {
	auth = strings.TrimSpace(auth)
	enc := base64.StdEncoding
	buf := make([]byte, enc.DecodedLen(len(auth)))
	n, err := enc.Decode(buf, []byte(auth))
	if err != nil {
		return "", "", false
	}
	auth = string(buf[:n])
	colon := strings.Index(auth, ":")
	if colon == -1 {
		return "", "", false
	}
	return auth[:colon], auth[colon+1:], true
}
func decodeBase64Credentials ( auth string ) ( user , pass string , ok bool ) { auth = strings . TrimSpace ( auth ) enc := base64 . StdEncoding buf := make ( [ ] byte , enc . DecodedLen ( len ( auth ) ) ) n , err := enc . Decode ( buf , [ ] byte ( auth ) ) if err != nil { return " " , " " , false } auth = string ( buf [ : n ] ) colon := strings . Index ( auth , " " ) if colon == - 1 { return " " , " " , false } return auth [ : colon ] , auth [ colon + 1 : ] , true }
decodeBase64Credentials decodes a base64-encoded username:password pair
such as those used in HTTP basic authentication.
decodeBase64Credentials decodes a base64 - encoded username : password pair such as those used in HTTP basic authentication .