The dissected thing about the development of iOS (one)

Source: Internet
Author: User

Objective:

A while ago, the manager suddenly came to me and said: Can I encrypt cached images in my project? Then I was puzzled and said, "Yes, but why do you do it?" What's the point?

As we all know,Apple uses a sandbox mechanism:One way to run an application in a restricted security environment, which is to limit the code access permissions granted to an application.

So there is the question: Why do you want to encrypt the cached picture? So the manager immediately called to the customer said the reason, feel no need to do encryption. But the answer is: there is a jailbreak mobile phone can see .... I have no words ??。

There is no way, then think of ways to chant. There are two scenarios that come to mind immediately:

(1) The network request down the picture URL (imgurl) manually encrypted storage.

(2) modify third-party libraries (e.g.Emasyncimageview,sdwebimage , etc.).

Here are a few words:

1, network request down the picture URL (imgurl) manually encrypted storage

The approximate code is this:

UIImage *image = [[UIImage alloc]init];         *imagedata = uiimagepngrepresentation (image);         // encrypt into data type    NSData *base64data = [imageData base64encodeddatawithoptions:0];         // encrypt into a string    NSString *base64string = [imageData base64encodedstringwithoptions:0];

Then store the data or base64string locally on the line. Read the first to decrypt, in use can be

Specific base64 Plus decryption can be seen :Base64 encryption and DES encryption, and DES Encryption Unity issues in JAVA and IOS

2, modify third-party libraries (ex: Emasyncimageview, Sdwebimage, etc.)

This kind of solution is more troublesome, of course, this kind of trouble is not to say the change is troublesome, later maintenance is also a problem.

2.1, Emasyncimageview

This library is relatively early, it is estimated that in addition to the old project, now use is not much. Worth mentioning: This library is not like sdwebimage , it is a direct return to the ImageView.

This is probably how it is used:

#import " EMAsyncImageView.h " @property (Weak, nonatomic) Emasyncimageview    *= [Nsurl Urlwithstring:imgurl];  
2.2, Sdwebimage

The use of sdwebimage, now more things, is very popular, is also very simple.

 objective-c:   #import  < Sdwebimage/uiimageview+webcache.h>//  ( The header file I added when I used: #import "uiimageview+webcache.h")   [ImageView sd_setimagewithurl:[ Nsurl urlwithstring:  @ " http://                 Www.domain.com/path/to/image.jpg    @ " placeholder.png  ]];   

For use there is not much to say. Let me say a little bit about ideas here. If you have seen sdwebimage , you will know. This diagram is also cached for the first load of the image, and the next time the load is read directly from the local, the benefits are self-evident. And in order to ensure the uniqueness of the picture:sdwebimage 's approach is to encrypt the name of the image to ensure the uniqueness of the picture.

So now get to the point: how to encrypt sdwebimage cached images? In fact, the approach is very simple, the method is the same as manual image encryption. As for the code inside the associated sdwebimage , this is the key.

But the only drawback is that there are multiple projects that are cumbersome to modify and project maintenance difficult.

3, ios-- jailbreak detection

Then the reply to the manager: This function can be achieved, but time-consuming and laborious, not good maintenance. This is just a function to prevent jailbreak phone use, pay and effect is not proportional (after all, jailbreak mobile phone accounted for a few).

But the question was still there, and there was another idea: to prevent the project from escaping. app to jailbreak your phone: You can't install apps if you're jailbroken .

This is a very bad thing to be done here. ??????????????????

Specific anti-jailbreak methods I will not list, you can see here, very detailed:iOS Jailbreak detection Summary and code implementation (jailbreak)

The dissected thing about the development of iOS (one)

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.