0

I have a question about encrypted images in kotlin android. In my case I used kali linux to treat the pictures and the following command (ImageMagick 6.9.11) to convert my jpg is:

convert pic01.jpg -encipher paraphrase.txt encryptedpic01.jpg

So it's ok. When I open the image is encrypted. It looks like an old tv with no signal. After that I copy this image into my android app drawable folder. So It loads as encrypted is. I used this lines of code:

var id: Int
val file = "e$filename"
id = resources.getIdentifier(file, "drawable", packageName)
if (id > 0) {
    binding.imgFoto.setImageResource(id)
}

I wonder if it's possible to decrypt the image passing its paraphrase.txt. Any recommendation to handle encrypted images from drawable folder using kotlin in Android studio? I would like to show the picture decrypted in an ImageView. Thanks in advance.

enter image description here

GSandro_Strongs
  • 773
  • 3
  • 11
  • 24
  • 1
    Can you update your question to include a broader overview about what you'd like to achieve? I ask because your question reminds me of the [XY Problem] (https://meta.stackexchange.com/questions/66377/what-is-the-xy-problem) and there might be a better way to do what you want. – aSemy Sep 22 '21 at 06:20
  • Yes thanks. I would like to show the picture in an imageview, but i don't know how to decrypt in kotlin code. – GSandro_Strongs Sep 23 '21 at 16:49
  • 1
    Okay, that's clear. Can I ask why you want to do that? I ask because I think using a command line tool and an Android app to separately encrypt and decrypt an image is unusual, and so difficult. What's the story? Why are you using ImageMagick rather than Android's Cipher ([example](https://stackoverflow.com/q/40123319/4161471))? – aSemy Sep 24 '21 at 07:43
  • I used imageMagick because I had a bunch of images and after encrypting I will copy in drawable folder. I mean I don't want to encrypt in the app, or its it the only opcion? The overall reason is avoiding decompile and see easily the iamges. – GSandro_Strongs Sep 24 '21 at 19:03
  • My mistake - Cipher is Java, not just Android, so you could use that https://www.baeldung.com/java-cipher-class. If you just want the images to be un-viewable, what about doing a base64 encode on the bytes? https://stackoverflow.com/a/58903654/4161471 – aSemy Sep 27 '21 at 16:54

0 Answers0