//// CryptMD5.m// CryptMD5//// Created by andyliu on 2018/10/12.//#import "CryptMD5.h"#import <CommonCrypto/CommonCrypto.h>#define CC_MD5_DIGEST_LENGTH 16#define ROUNDS 1000staticunsignedchar itoa64[]=/* 0 ... 63 => ascii - 64 */"./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";staticvoidto64(char*s,unsignedlong v,int n){
while(--n >=0){
*s++= itoa64[v &0x3f];
v >>=6;}}/*
*/char*md5Crypt(constchar*password,unsignedint passwordLength,constchar*salt,unsignedint saltLength,constchar*prefix,unsignedint prefixLength){
constunsignedint keyLen = passwordLength;char*thePrefix =(char*)prefix;if(thePrefix == nil){
thePrefix ="$1$";}
CC_MD5_CTX md5Context;CC_MD5_Init(&md5Context);/*
* The password first, since that is what is most unknown
*/CC_MD5_Update(&md5Context, password, keyLen);/*
* Then our magic string
*/CC_MD5_Update(&md5Context, thePrefix, prefixLength);/*
* Then the raw salt
*/CC_MD5_Update(&md5Context, salt, saltLength);
CC_MD5_CTX md5Context1;CC_MD5_Init(&md5Context1);/*
* Then just as many characters of the MD5(pw,salt,pw)
*/CC_MD5_Update(&md5Context1, password, keyLen
Objective-C代码实现//// CryptMD5.m// CryptMD5//// Created by andyliu on 2018/10/12.//#import &quot;CryptMD5.h&quot;#import &amp;lt;CommonCrypto/CommonCrypto.h&amp;gt;#define CC_MD5_DIGEST_LENGTH 16#define ...