SOURCE 0603-10-Mastering-MD5 encryption -11-Mastering-https

Source: Internet
Author: User
Tags md5 encryption

////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

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.