Android/iOS 上的 Base64 编码图像
我正在寻找一种混淆存储在应用程序中的图像的方法,目前正在考虑使用 Base46 编码。
我需要一些开销最小的东西,或者如果可能的话,比文件系统上的标准文件性能提升。
有人可以评论一下对图像(png)进行base64编码并随后在目标平台上使用(解码?)的可行性吗?
谢谢。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您想要防范哪种类型的攻击? Base64 相当容易识别并且在空间方面具有潜在的重大影响(每个图像将占用额外 33% 的空间)。
仅从数据中很难发现某种变化的异或,但它不足以保护真正重要的资产。
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.
我相信您明白 Base64 不会欺骗任何真正想要获取您的位图的人。
Jon Skeet 是对的,Base64 很适合以可读格式对二进制数据进行编码,但在这里并不能真正帮助您。对您的密码进行异或运算会更快,并且不会增加任何大小开销。
如果您确实想混淆位图,我建议您将它们存储在“raw”资源文件夹中。通过这样做,您将能够保留处理不同外形尺寸(ldpi、hdpi...)的良好 Android 抽象。
扩展 ImageView 类以直接使用 R.raw.filename id 并在那里读取文件/解码流/创建位图。通过这样做,您将能够在需要时轻松回滚到标准的处理方式。
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 withR.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.请注意,在 Android 的应用程序内存中存储多个位图时,您可能会遇到内存问题。在 android 中处理位图时,OutOfMemoryErrors 似乎是一个反复出现的问题。这是一个示例: outofmemoryerror-bitmap-size-exceeds-vm-budget-android
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