Skip to content

Commit

Permalink
fix(android): add extension to encrypted assets (#11351)
Browse files Browse the repository at this point in the history
* fix(android): add extension to encrypted assets

* fix(android): update template to include extension
  • Loading branch information
garymathews authored and ssekhri committed Nov 19, 2019
1 parent 8ac7eec commit bf8a6bf
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion android/cli/commands/_build.js
Original file line number Diff line number Diff line change
Expand Up @@ -2832,7 +2832,7 @@ AndroidBuilder.prototype.copyResources = function copyResources(next) {
await Promise.all(
jsFilesToEncrypt.map(async file => {
const from = path.join(this.buildAssetsDir, file);
const to = path.join(this.buildBinAssetsResourcesDir, file);
const to = path.join(this.buildBinAssetsResourcesDir, file + '.bin');

this.logger.debug(__('Encrypting: %s', from.cyan));
await fs.ensureDir(path.dirname(to));
Expand Down
5 changes: 5 additions & 0 deletions android/templates/build/AssetCryptImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ public class AssetCryptImpl implements KrollAssetHelper.AssetCrypt
{
private static final String TAG = "AssetCryptImpl";

private static final String BIN_EXT = ".bin";

private static byte[] salt = {
<% for (let i = 0; i < salt.length - 1; i++){ -%>
<%- '(byte)' + salt.readUInt8(i) + ', ' -%>
Expand Down Expand Up @@ -73,6 +75,9 @@ private static InputStream getAssetStream(String path)
if (!assets.contains(path)) {
return null;
}
if (!path.endsWith(BIN_EXT)) {
path = path + BIN_EXT;
}
try {
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
cipher.init(Cipher.DECRYPT_MODE, new SecretKeySpec(ti.cloak.Binding.getKey(salt), "AES"), new IvParameterSpec(salt));
Expand Down

0 comments on commit bf8a6bf

Please sign in to comment.