MD5 String Encryption IOS

Source: Internet
Author: User

An example of a MD5 encryption. http://code.cocoachina.com/detail/117150

How to use:

1. Add the MyMD5.h and MYMD5.M files from your project to your project

2. Import #import "MyMD5.h" in your class

3. Call the MyMD5 class method [MyMD5 md5:@ "Testtext"];

Define yourself a NSObject class MyMD5.h
Write a factory method + (nsstring *) MD5: (nsstring *) Inputtext;

This method is implemented in MYMD5.M

#import "Commoncrypto/commondigest.h"

+ (NSString *) MD5: (NSString *) Inputtext

{

const Char *cstr = [Inputtext utf8string];

unsigned char result[cc_md5_digest_length];

cc_md5 (cStr, strlen (CSTR), result);

return [[nsstring stringwithformat: @]%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%0 2x%02x%02x%02x ",

result[0], result[1], result[2], result[3],

result[4], result[5], result[6], result[7],

result[8], result[9], result[,result[],

Result[], result[[], result[], result[]

] lowercasestring];

}

MD5 String Encryption IOS

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.