Created
October 21, 2019 09:50
-
-
Save drrost/3c5c9593d65c938891464c9cee955241 to your computer and use it in GitHub Desktop.
Swift basic auth
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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