I am trying to post the username and password to the server. I want to convert this username and password into Base64 Encoding. So this encoded string will be added for the Authorization field.
Is there any API already available to do the Base64 encoding in iOS or we have write on our own ??
This can be done by implementing a class method for base64 conversion the below code is for conversion..
and in your URL request add the following code for to sent the username and password for authorization...
[request addValue:[NSString stringWithFormat:@"Basic %@",[className base64forData:[[NSString stringWithFormat:@"%@:%@",UsernameString,passwordString] dataUsingEncoding: NSUTF8StringEncoding]]] forHTTPHeaderField:@"Authorization"];
How do I do base64 encoding on iphone-sdk?
Have a look at this.
and then use these methods to make use of the above methods(given in link) Converting NSString to Base64 Data for XML Serialization taken from above link.