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