Android Encryption/decryption Issue (aes)
Solution 1:
About loading the encrypted image:
You can use the /assets
folder, is in your workspace at the same level than /res
. Then you place the file inside. Let's say it is called "myfile.enc". You should use the AssetManager
to retrieve the file:
AssetManageram= activity.getAssets();
InputStreamis= am.open("myfile.enc");
With the InputStream, you can write it to a ByteArrayOutputStream
and then get the bytes, or you could pass it to a CipherInputstream
instead of calling Cipher.doFinal
. This is the way to go if you have a relatively large resource. But for your little test, I think the byte version is the easiest.
To get the Bitmap thing working, I would also put it under assets folder and then get the bytes with the same procedure. The drawables folder is generally for images you are going to use in the GUI, so you can use their ID's on R.java.
Solution 2:
Two things:
-You are performing an extensive task on the Ui Thread (AKA event thread). This is very bad way of doing things, because you are blocking the GUI, and if you spend too much time on it, the OS will launch the "Application not responding" error.
-I think you are not launching a View in the onCreate.
Post a Comment for "Android Encryption/decryption Issue (aes)"