<span id="Label3"><p>Valid in IOS7 and later:</p><p></p><p>Base64 encoding</p><p>-(nsstring*) base64encode: (nsstring*) Str {</p><p>1. Turning strings into binary data</p><p>nsdata* data = [str datausingencoding:nsutf8stringencoding];</p><p></p><p>2. Base64 encryption (encoding) of the binary</p><p>The way that iOS7 later.</p><p>return [data base64encodedstringwithoptions:0];</p><p>}</p><p></p><p>Base64 decoding</p><p>-(nsstring*) base64decode: (nsstring*) Str {</p><p></p><p>1. Turn base64 encoded string into binary data first</p><p>nsdata* data = [[nsdata alloc] initwithbase64encodedstring:str options:0];</p><p></p><p>2. Turn data into a string</p><p>return [[nsstring alloc] initwithdata:data encoding:nsutf8stringencoding];</p><p></p><p>}</p><p></p><p>Base64 decoding and encoding in iOS</p></span>
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service