Created
March 11, 2021 16:13
-
-
Save dudego/d2a84d42f39f1f53915a11a3e223865f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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