Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Saving secure data into keychain wrapper for app security

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 662
    Comment on it

    Hi Readers,

    The keychain service provide a secure way to store content such as passwords, keys, certificates, etc. Each iOS app has a separate requirement to save items. There is a class named KeychainItemWrapper which provide you service to save data into keychain and retrieve it later as per the requirement. You need to first download KeychainItemWrapper class which is available in Apple library documents. After download these files include these into your project and follow below code to save username, password into keychain:

    KeychainItemWrapper *keychain = [[KeychainItemWrapper alloc] initWithIdentifier:@"YourAppIdentifier" accessGroup:nil];

    These lines will create with identifier same as your app identifier. Now you will save username and password as:

    // Store username to keychain
    [keychain setObject:@"usernameText" forKey:(id)kSecAttrAccount]; 
    
    // Store password to keychain 
    [keychain setObject:@"passwordText" forKey:(id)kSecValueData]; 

    We can later get values of these by following code:

    //Get username
    NSString *usernameText = [keychain objectForKey:(id)kSecAttrAccount];
    
    //Get password
    NSString *passwordText = [keychain objectForKey:(id)kSecValueData]

     

    Thanks for reading.

     

     

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: