Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the best practice to store username and password on the iPhone?

Is there a best practice way to store username and password on the iPhone? I am looking for something that is obviously secure but will also keep the info between app updates.

like image 293
Jason Avatar asked Oct 08 '09 14:10

Jason


People also ask

What is the safest way to store passwords on iPhone?

With iCloud Keychain, you can keep your passwords and other secure information updated across your devices. iCloud Keychain remembers things, so that you don't have to.

Is it safe to store keychain passwords iPhone?

Everything stored in iCloud Keychain is secure—it's protected by industry-standard encryption. Your iCloud Keychain can't be set up on another Mac or iOS or iPadOS device unless you approve it.


1 Answers

Use the Apple Keychain.

+ (NSString *) getPasswordForUsername: (NSString *) username andServiceName: (NSString *) serviceName error: (NSError **) error;

+ (void) storeUsername: (NSString *) username andPassword: (NSString *) password forServiceName: (NSString *) serviceName updateExisting: (BOOL) updateExisting error: (NSError **) error;

The first method allows you to request the password associated with an existing username for a particular service name (I’ve just been using the name of my app as a service name). The second allows you to store a username/password/service name combo, and allows you to specify whether or not the appropriate keychain item should be updated with the provided password if an existing one is found that matches the username and service name pair. The last parameter of each is a reference to an NSError object which will contain lower level error information if something goes wrong (and be nil if it does not).

For more information see his blog

like image 160
jantimon Avatar answered Nov 10 '22 10:11

jantimon