kkkk
kkkk

Reputation: 121

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?

Upvotes: 5

Views: 1609

Answers (1)

Glenn
Glenn

Reputation: 12809

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);

Upvotes: 1

Related Questions