Created
September 20, 2018 09:15
-
-
Save Arrlindii/6fff4ba3d609123e4c153cc83c18749d 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
| class KeychainService { | |
| func save(_ password: String, for account: String) { | |
| let password = password.data(using: String.Encoding.utf8)! | |
| let query: [String: Any] = [kSecClass as String: kSecClassGenericPassword, | |
| kSecAttrAccount as String: account, | |
| kSecValueData as String: password] | |
| let status = SecItemAdd(query as CFDictionary, nil) | |
| guard status == errSecSuccess else { return print("save error") | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment