Parse Json from CipherInputStream very slow

I use CipherInputStream in my Android app for decrypt some files which encrypted by AES-256, size of each file about 2M. I put all of them into Assets folder and try to parse them. But unlucky, everything works well except performance that’s really slow compared to iOS, it takes about 5 seconds to parse per file. I found only one solution in Google which replace Android’s CipherInputStream by a custom class but it raise me EndOfFile Exception:BetterCipherInputStream

The below is my implement:
Decrypt code :
public static InputStream decryptInputStream(InputStream is, String _CIPHER_KEY) {
prepare(_CIPHER_KEY);
CipherInputStream cis = new CipherInputStream(is, cipher);
return cis;
}

Parse code :

public TreeMap> parseDVD(InputStream is) {
while (jsonReader.hasNext()) {
String root = jsonReader.nextName();
Log.w("", "_" + root);
if (root.equalsIgnoreCase("search")) {
Map[] searchOptions = gson.fromJson(jsonReader, new TypeToken[]>() {}.getType());
....
}

Get Asset file and parse :
jsonParser.parseDVD(Decripter.decryptInputStream(assetUtils.inputStreamFromFileName("mydata.data"), Define._CIPHER_KEY));


Do you have any idea to help me improve the performance ?


Source: json

Leave a Reply