MCPcopy Create free account
hub / github.com/docker/cli / encodeAuth

Function encodeAuth

cli/config/configfile/file.go:284–294  ·  view source on GitHub ↗

encodeAuth creates a base64 encoded string to containing authorization information

(authConfig *types.AuthConfig)

Source from the content-addressed store, hash-verified

282
283// encodeAuth creates a base64 encoded string to containing authorization information
284func encodeAuth(authConfig *types.AuthConfig) string {
285 if authConfig.Username == "" && authConfig.Password == "" {
286 return ""
287 }
288
289 authStr := authConfig.Username + ":" + authConfig.Password
290 msg := []byte(authStr)
291 encoded := make([]byte, base64.StdEncoding.EncodedLen(len(msg)))
292 base64.StdEncoding.Encode(encoded, msg)
293 return string(encoded)
294}
295
296// decodeAuth decodes a base64 encoded string and returns username and password
297func decodeAuth(authStr string) (string, string, error) {

Callers 3

TestEncodeAuthFunction · 0.85
SaveToWriterMethod · 0.85

Calls

no outgoing calls

Tested by 2

TestEncodeAuthFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…