MD5 encryption of iOS development practices

Source: Internet
Author: User
Tags md5 encryption

What is MD5:

Full name is Message Digest Algorithm 5 , translated into " Message digest Algorithm section 5 version "

effect: Generates unique input information for the - bit hash value ( + characters)


MD5 Features of:

Input two different plaintext does not get the same output value

according to the output value, the original plaintext cannot be obtained, i.e. its process Non-reversible


MD5 Application of:

because MD5 encryption algorithm has good security, and free, so the encryption algorithm is widely used

Mainly used in digital signature, file integrity verification and password encryption and other aspects


MD5 improvements:

Add salt ( Salt ): Inserts a random string in the fixed position of the clear text and then MD5

first encryption, after the chaos: First in clear text MD5 , and then to encrypt the resulting MD5 string of characters in order of Chaos


Chestnuts:

Import NSSTRING+HASH.H encapsulated encryption classification algorithm: HTTP://PAN.BAIDU.COM/S/1O7HA4VW


Viewcontroller.m

Viewcontroller.m#import "ViewController.h" #import "nsstring+hash.h" @interface Viewcontroller () @       End@implementation viewcontroller-(void) viewdidload {[Super viewdidload];        [Self MD5];        [Self md5salt:@ "san"];        [Self doubleMD5]; [Self md5reorder];}    MD5 Encryption-(void) md5{nsstring *pwd = @ "123456";    NSString *pwdmd5 = [pwd md5string];    NSLog (@ "%@", pwdMD5);    }/** * Salt Encryption MD5 ($pass. $salt) */-(void) Md5salt: (NSString *) salt{nsstring *pwd = @ "123456"; PWD =[pwd Stringbyappendingstring:salt];    Sprinkle salt: Randomly insert any string into the plaintext nsstring *pwdmd5 = [pwd md5string]; NSLog (@ "%@", pwdMD5);}    /** * MD5 (MD5 ($pass)) */-(void) doublemd5{nsstring *pwd = @ "123456";    NSString *pwdmd5md5 = [[pwd md5string]md5string]; NSLog (@ "%@", PWDMD5MD5);}    /** * First encrypted, after the disorderly sequence */-(void) md5reorder{nsstring *pwd = @ "123456";    NSString *pwdmd5 = [pwd md5string];    NSLog (@ "oldpwdmd5=%@", pwdMD5); NSString *prefix = [pwdMD5 substringfromindex:3]; Intercept starting from Subscript 3 (contains 3) NSString *subfix= [PwdMD5 Substringtoindex:3];    Intercepts 0 to 3 of the string (not including 3) pwdMD5 = [prefix stringbyappendingstring:subfix]; NSLog (@ "newpwdmd5=%@", pwdMD5);} @end




MD5 encryption of iOS development practices

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.