Created
August 23, 2019 14:38
-
-
Save araeuchle/ce7b72d618a9d35e56e0220e56a3b25a to your computer and use it in GitHub Desktop.
This file contains hidden or 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
func encode(apiKey: String) throws -> String { | |
guard let apiKeyData = "api:\(apiKey)".data(using: .utf8) else { | |
throw Error.encodingProblem | |
} | |
let authKey = apiKeyData.base64EncodedData() | |
guard let authKeyEncoded = String.init(data: authKey, encoding: .utf8) else { | |
throw Error.encodingProblem | |
} | |
return authKeyEncoded | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment