Use 3des+base64 to encrypt the transfer of iOS app data

Source: Internet
Author: User
Tags asymmetric encryption

this article reprinted to Http://www.erblah.com/post/objective-c/shi-yong-3des-base64lai-jia-mi-chuan-shu-iosying-yong-shu-ju app and server data transmission sometimes need to encrypt, in order to avoid a well-known news client password just MD5 a bit to the predicament of the post ...

There are three types of iOS encryption: 1.https 2. Symmetric encryption 3. Asymmetric encryption, for various reasons, the use of 3DES symmetric encryption in one application (said AES better), feel very convenient.

The code has done some tidying up, providing two implementations of object and Nsstring+category, along with the server-side encryption and decryption Code (PHP implementation), the needs of students can be used.
GitHub Address: Er3desencryptandserver

Instructions for use Er3desencryptandserveruseage
    • Use Er3desencrypt
#import "ER3DESEncrypt.h"...NSString*Orig=@ "Erblah.com",*EncryptString,*Decryptstring,*Key=@ "I love you.";Default key:abcd12345678901234567890Er3desencrypt*Encryptdefaultkey=[[Er3desencryptAlloc]Init];EncryptString=[EncryptdefaultkeyEncryptString:Orig];Decryptstring=[EncryptdefaultkeyDecryptstring:EncryptString];NSLog(@ "key:%@\ n%@ --- %@ --- %@",Encryptdefaultkey.Encryptkey,Orig,EncryptString,Decryptstring);Custom keyEr3desencrypt*Encryptcustomkey=[[Er3desencryptAlloc]Initwithkey:Key; encryptstring = [encryptcustomkey encryptstring:orig]; decryptstring = [encryptcustomkey decryptString< Span class= "o" >:encryptstring]; Nslog (@ "Key:%@\n%@---%@---%@"  , encryptdefaultkey. Encryptkeyorigencryptstringdecryptstring           
    • Use Category (nsstring+encrypt3desandbase64)
#import "Nsstring+encrypt3desandbase64.h"...NSString*Orig=@ "Erblah.com",*EncryptString,*Decryptstring,*key = @ "I Love you." encryptstring = [orig  Encryptstringwithkey:key]; decryptstring = [encryptstring  Decryptstringwithkey:key]; Nslog (@ "Key:%@\n%@---%@---%@"  , keyorigencryptstringdecryptstring         
    • Server (PHP)

      ^_^, open crypt3des.php ...

Use 3des+base64 to encrypt the transfer of iOS app data

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.