Hamid
Hamid

Reputation: 4430

Base64 Encoded images on Android/iOS

I'm looking for a way of obfuscating the images I store in my application and am currently considering Base46 Encoding.

I need something with minimal overhead or if possible a performance boost over standard files on the file system.

Can someone comment on the feasability of base64 encoding the images (png) and subsequently using (decoding?) on the target platforms?

Thanks.

Upvotes: 0

Views: 2636

Answers (3)

Twobard
Twobard

Reputation: 2583

Be warned that you could run into memory issues when storing multiple bitmaps within an application memory in Android. OutOfMemoryErrors seem to be a recurring problem when dealing with bitmaps in android. Here is an example: outofmemoryerror-bitmap-size-exceeds-vm-budget-android

Upvotes: 0

pcans
pcans

Reputation: 7651

I am sure you understand Base64 won't fool anyone who really want to get your Bitmap.

Jon Skeet is right, Base64 is nice to encode binary data in readable format but will not really help you here. An XOR against a password of yours will be faster, and won't add any size overhead.

If you really want to obfuscate your bitmaps I suggest you to store them in the "raw" ressources folder. By doing this you will be able to keep the nice Android abstraction that handles different form factors (ldpi, hdpi, ...). Extends the ImageView class to directly work with R.raw.filename id and do the reading file/decoding stream/creating bitmap there. By doing so, you will be able to rollback easily to the standard way of doing things if needed.

Upvotes: 0

Jon Skeet
Jon Skeet

Reputation: 1500873

What sort of attack are you trying to protect against? Base64 is reasonably easily recognizable and has a potentially-significant impact in terms of space (each image will take an extra 33% space).

Some sort of shifting XOR would be harder to spot just from the data, but it wouldn't be adequate protection for really significant assets.

Upvotes: 2

Related Questions