Re: convert password from SecKeychainFindGenericPassword to NSString
Re: convert password from SecKeychainFindGenericPassword to NSString
- Subject: Re: convert password from SecKeychainFindGenericPassword to NSString
- From: Kyle Sluder <email@hidden>
- Date: Sun, 31 Jan 2010 18:12:23 -0800
On Sun, Jan 31, 2010 at 5:51 PM, Stuart Malin <email@hidden> wrote:
> I acquire a password from a keychain using SecKeychainFindGenericPassword. That provides a non null terminated c string and a length. I had been using [NSString stringWithCString: length:] to get an NSString instance of the password. However, the +stringWithCString:length: method was deprecated way back, so I thought I'd clean up my code and use +stringWithCString:encoding: -- however that doesn't work because the supplied C string isn't null terminated. I did a bit of searching, and found in the archives on CocoaBuilder [1] someone's solution back in September of 2005, which was to copy the acquired password to a new buffer of 1 additional byte and create a new null terminated C string there:
You could wrap the provided buffer with an NSData and use -[NSString
initWithData:encoding:].
--Kyle Sluder
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden