Skip to content

Instantly share code, notes, and snippets.

@drrost
Created October 21, 2019 09:50
Show Gist options
  • Save drrost/3c5c9593d65c938891464c9cee955241 to your computer and use it in GitHub Desktop.
Save drrost/3c5c9593d65c938891464c9cee955241 to your computer and use it in GitHub Desktop.
Swift basic auth
#!/usr/bin/swift
import Foundation
func basicAuth(_ username: String, _ password: String) -> String {
let auth = username + ":" + password
let authData = auth.data(using: .utf8)!
return authData.base64EncodedString()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment