Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Data encryption for the resources in android

I am using database files and some text files which I have put in the Assets folder. When any user downloads my APK file and extracts it, he will get my resources from the assets folder easily.

How can I encrypt all my resources so that if anyone gets my resources, he can't use it?

like image 305
kkkk Avatar asked Nov 09 '22 22:11

kkkk


1 Answers

Assuming the asset file is already encrypted, Java's CipherInputStream to decrypt content of the asset file would help your need

// Cipher that holds algorithm (E.g. AES)
Cipher cipher = getCipherProbablyAES();


// Get input stream to that file. Handle IOException on your own
InputStream assetFile = getAssets().open("myEncrypted.txt");
CipherInputStream cipherIS = CipherInputStream(assetFile, cipher);
like image 167
Glenn Avatar answered Nov 15 '22 11:11

Glenn