HTTP Basic Authorization (with iOS implementation method)

Source: Internet
Author: User

A concept

HTTP Basic authentication is a way to allow a Web browser, or other client program, to provide credentials in the form of a user name and password when requested. The user name appends a colon and then strings the password, the resulting string is then encoded with the BASE64 algorithm. For example, the user name
is: admin, password is: admin123, stitching after the result is: admin:admin123, and then use Base64 code, get ywrtaw46ywrtaw4xmjm=. The BASE64 encoded string is sent out and decoded by the receiver, resulting in a string of user names and passwords separated by colons.

Application in iOS two

-(NSString *) Gethttptokenwith: (NSString *) token{    nsstring *base64token  = [NSString stringwithformat:@ "Basic %@ ", [token base64string]];    return Base64token;}
  Nsmutableurlrequest *request = [nsmutableurlrequest requestwithurl:[nsurl urlwithstring:aurl];    [Request Setvalue:[self gethttptokenwith:@ "<span style=" Color:rgb (0, 0, +); font-family: ' Hiragino Sans GB W3 ', ' Hir Agino Sans GB ', Arial, Helvetica, SimSun, u5b8bu4f53; font-size:16px; line-height:28px; " >admin123</span> "] forhttpheaderfield:@" Authorization "];




Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

HTTP Basic Authorization (with iOS implementation method)

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.