Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Converting NSData to base64

How to convert NSData to base64. I have NSData and want to convert into base64 how can I do this?

like image 298
mactalent Avatar asked Feb 04 '10 04:02

mactalent


People also ask

Can we convert file to Base64?

Convert Files to Base64Just select your file or drag & drop it below, press the Convert to Base64 button, and you'll get a base64 string. Press a button – get base64. No ads, nonsense, or garbage. The input file can also be an mp3 or mp4.

Is BTOA a Base64?

btoa() The btoa() method creates a Base64-encoded ASCII string from a binary string (i.e., a string in which each character in the string is treated as a byte of binary data).


1 Answers

EDIT

As of OS X 10.9 / iOS 7, this is built into the frameworks.

See -[NSData base64EncodedDataWithOptions:]


Prior to iOS7/OS X 10.9:

Matt Gallagher wrote an article on this very topic. At the bottom he gives a link to his embeddable code for iPhone.

On the mac you can use the OpenSSL library, on the iPhone he writes his own impl.

like image 122
Ken Avatar answered Sep 22 '22 08:09

Ken