////VIEWCONTROLLER.M//10-Mastering-MD5 Encryption#import "ViewController.h" #import "nsstring+hash.h"@interfaceViewcontroller ()@end@implementationViewcontroller- (void) viewdidload {[Super viewdidload]; //user input or 520it//Encryption: 21bfcc4c2625469d8ec6f3d710dcb0fe//Disorderly Order: 21bfcc4c2625469d8ec6f3d710dcb0fe nsstring *text = @ "520it"; NSString *MD = [text md5string]; NSLog (@ "%@" , MD);}@end
////VIEWCONTROLLER.M//11-Mastering-https#import "ViewController.h"@interfaceViewcontroller ()<NSURLSessionTaskDelegate>@end@implementationViewcontroller- (void) viewdidload {[Super viewdidload]; Nsurlsession*session = [Nsurlsessionsessionwithconfiguration:[Nsurlsessionconfigurationdefaultsessionconfiguration]Delegate: Self delegatequeue:[[Nsoperationqueue alloc] init]; Nsurlsessiondatatask*task = [sessionDatataskwithurl:[Nsurl URLWithString:@"https://www.apple.com/"]Completionhandler:^ (NSData *data, Nsurlresponse *response, Nserror *error) {NSLog (@"%@", [[NSString alloc] Initwithdata:data encoding:nsutf8stringencoding]); }]; [task resume];}#pragmaMark-<NSURLSessionTaskDelegate>/** Challenge: Challenge, Question * Completionhandler: Tell Urlsession to receive this certificate by calling this block */- (void)urlsession:(Nsurlsession *) sessionTask:(Nsurlsessiontask *) taskDidreceivechallenge:(Nsurlauthenticationchallenge *) challengeCompletionhandler:(void(^) (Nsurlsessionauthchallengedisposition, Nsurlcredential *))completionhandler{ //If the certificate is not a server trust type, return directly if(! [Challenge.protectionSpace.authenticationMethodisequaltostring:Nsurlauthenticationmethodservertrust])return; //void (^) (nsurlsessionauthchallengedisposition, nsurlcredential *)//nsurlsessionauthchallengedisposition: How to handle this security certificate//nsurlcredential: Security certificate//Create a Certificate object based on the trust information of the server//nsurlcredential *crdential = [nsurlcredential credentialfortrust: Challenge.protectionSpace.serverTrust]; //Use this block to illustrate using this certificate//if (completionhandler) {//Completionhandler (nsurlsessionauthchallengeusecredential, crdential);// } !completionhandler? : Completionhandler (nsurlsessionauthchallengeusecredential, challenge.proposedcredential);}@end
SOURCE 0603-10-Mastering-MD5 encryption -11-Mastering-https