IOS-MD5 encryption 32-bit extension class

Source: Internet
Author: User
Tags md5 encryption

Nsstring+md5.h

////  NSString+MD5.h//  Spread////  Created by 邱学伟 on 16/4/26.//  Copyright ? 2016年 邱学伟. All rights reserved.//#import <Foundation/Foundation.h>@interface NSString (MD5)/** 将字符串经MD5加密 */+(NSString *)MD5:(NSString *)str;@end

Nsstring+md5.m

////Nsstring+md5.mspread////Created by Chu Cowei on -/4/ -.//Copyright? .Year Chu Cowei. All Rights reserved.//#import "Nsstring+md5.h"#import <CommonCrypto/CommonDigest.h>@implementationNSString (MD5)/**Encrypt a string by MD5*/+ (NSString*)MD5: (nsstring*)str{const Char*cstr= [Str utf8string]; unsigned char result[ -]; CC_MD5 (CStr, strlen (CSTR), result);//The MD5 call NSLOG (@"Md5->>>>>>%@", [NSString stringWithFormat: @"%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x  %02x%02x%02x%02x", result[0], result[1], result[2], result[3], result[4], result[5], result[6], result[7], result[8], result[9], result[Ten], result[ One], result[ A], result[ -], result[ -], result[ the]                           ]);return[NSString stringWithFormat:@"%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x", Result[0], result[1], result[2], result[3], result[4], result[5], result[6], result[7], RESULT[8], result[9], result[10], result[11], result[12], result[13], result[14], result[15]] ;} @end 

IOS-MD5 encryption 32-bit extension class

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.