Skip to content

Instantly share code, notes, and snippets.

@dudego
Created March 11, 2021 16:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dudego/d2a84d42f39f1f53915a11a3e223865f to your computer and use it in GitHub Desktop.
Save dudego/d2a84d42f39f1f53915a11a3e223865f to your computer and use it in GitHub Desktop.
String encryptedStr = readFromAsset(context, BuildConfig.ENC_FILE);
String decryptedData = getDecryptedString(responseStr);
public String readFromAsset(Context context, String fileName) {
String json = null;
try {
InputStream is = context.getAssets().open(fileName);
int size = is.available(); byte[] buffer = new byte[size];
is.read(buffer);
is.close();
json = new String(buffer, "UTF-8");
} catch (IOException ex) {
Logger.e(ex); return null;
}
return json;
}
public static String getDecryptedString(String text) {
Encryption encryption = Encryption.getDefault(BuildConfig.ENC_KEY, BuildConfig.ENC_SALT, IV);
return encryption == null ? "" : encryption.decryptOrNull(text);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment