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)