Check sum in iOS

/
0 Comments
This article will help u how to use https://github.com/JoeKun/FileMD5Hash to check sum data.
1. Import FileMD5Hash.h and FileMD5Hash.m into your project
2. In {Name of your project}-Prefix.pch file. Import this code
 // Extern  
 #if defined(__cplusplus)  
 #define FILEMD5HASH_EXTERN extern "C"  
 #else  
 #define FILEMD5HASH_EXTERN extern  
 #endif  
3. Create this function which return a MD5 string:
/** executablePath is a path in Bundle or Document **/
 + (NSString *)computeMD5HashOfBinary:(NSString *)executablePath {    
   NSString *result = @"";  
   NSFileManager *fileManager = [NSFileManager defaultManager];  
   if(![fileManager fileExistsAtPath:executablePath]) {  
     return result;  
   }  
   CFStringRef executableFileMD5Hash =   
   FileMD5HashCreateWithPath((CFStringRef)executablePath,   
                /*[size longValue]*/ FileHashDefaultChunkSizeForReadingData);  
   if (executableFileMD5Hash) {  
     result = [((NSString *)executableFileMD5Hash) retain];  
     CFRelease(executableFileMD5Hash);  
   }  
   return result;  
 }  
Well done ;)


You may also like

No comments:

Member of Mroom Software. Powered by Blogger.