Encrypt with the public Key for OpenSSL in iOS

Source: Internet
Author: User

These days have been concentrated on the development of iOS, just to record the problems encountered. The problem this time is that if the user name and password are encrypted on the iOS client based on the public key that is obtained.

The public key is as follows:

-----BEGIN Public KEY-----MIGFMA0GCSQGSIB3DQEBAQUAA4GNADCBIQKBGQCP0WHYBG/ nopo3nzmd3dndws0mccumexchgvlgooyyfwlds24im2e7yyhb0wrusyyf0/ nhzczbk8zc9ecwqd0ahbdgoqt6cufqbmjbygyvlvyu2zp7kg9ft6yv6oc9ambuo7npzh+  Bvxh0zdkfi02prknrscakc0xhadtht3al0qidaqab-----END Public KEY-----

Then Google search in iOS for RSA encryption, found several articles as follows:

RSA encryption method on IOS

RSA encryption method on IOS

After a closer look at these two articles, I found that they were all read from the file Public_key for encryption, and I encountered the scene is Public_key is given, rather than generate their own public_key to encrypt, so these two articles on my help is not much.

Then find this problem on StackOverflow, the link is: Encryption with the RSA public key on IOS, @ideawu have already exposed this encryption algorithm, and then according to their own attempts to find this method is feasible. The following is the direct call he wrote the method to encrypt, and the server side to decrypt the process of encryption and decryption completed.

NSString *encryptusername =*encryptpassword = [RSA encryptstring:password Publickey:pubkey];

Finally, if there is a problem accessing GitHub, I upload the RSA file to my space for easy download.

RSA file

Encrypt with the public Key for OpenSSL in 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.