GithubHelp home page GithubHelp logo

tkyaji / cordova-plugin-crypt-file Goto Github PK

View Code? Open in Web Editor NEW
178.0 29.0 116.0 35 KB

This plugin to encrypt the source files.

License: Apache License 2.0

JavaScript 42.99% Java 18.17% Objective-C 38.84%

cordova-plugin-crypt-file's Introduction

Cordova crypt file plugin

HTML source file is encrypted at build, and decrypted at run.
https://www.npmjs.com/package/cordova-plugin-crypt-file

Add Plugin

cordova plugin add cordova-plugin-crypt-file

Encrypt

cordova build [ios / android]

Decrypt

cordova emulate [ios / android]
or
cordova run [ios / android]

Encryption subjects.

Default

  • .html
  • .htm
  • .js
  • .css

Edit subjects

You can specify the encryption subjects by editing plugin.xml.

plugins/cordova-plugin-crypt-file/plugin.xml

<cryptfiles>
    <include>
        <file regex="\.(htm|html|js|css)$" />
    </include>
    <exclude>
        <file regex="exclude_file\.js$" />
    </exclude>
</cryptfiles>

Specify the target file as a regular expression.

Supported platforms

  • iOS
  • Android
  • CrossWalk

Before reporting your issue

It would be very helpful if you show me your project (If you have GitHub repository, that URL would be nice). It is very hard for me to reporduce your enviroment.

License

Apache version 2.0

cordova-plugin-crypt-file's People

Contributors

axelcostaspena avatar duddu avatar hanthomas avatar renandecarlo avatar s-s avatar tkyaji avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cordova-plugin-crypt-file's Issues

Thank you for cordova-plugin-crypt-file

Thank you very much for cordova-plugin-crypt-file.
I have encrypted files(.html, .htm, .js, .css) and run my application.

But, setting up cordova-plugin-device into my application,
cordova-plugin-device doesn't work.
My cordova version is 5.1.1.

I would appreciate if you could advice this comment.
Thank you in advance.

codes and symbols appears after clicking on android back button

Dears,

Kindly i need your usual support, regarding to the android back button.

After i added the Cordova encryption plugin when the user click on the android back button he got an error blank page with some symbols and cods. check the below picture.

enc error

Not working perferctly with ionic app.

I try your plugin in my ionic application after install crypt plugin in my app not show any data in display on screen. My app shows only white screen.

screenshot_2016-06-14-12-17-11

ionic support

I install this plugin for an ionic1 application, and the
ionic cordova run android crypt the project.
The documntation said that the run command do not crypt .. only the build crypth the files
The txt file attached is the log file of the project

crypt.txt

Support for Windows platform

I'm not sure if this is even possible, but it would nice if this supported Windows platform. I know that Cordova for Windows is simply a wrapper for WinJS, so it would probably depend upon whether or not WinJS allows overriding URI remap and file IO handling.

Response for preflight has invalid HTTP status code 405

I'm Using Ionic when i call ajax using angular js then This problem is rising "XMLHttpRequest cannot load https://***/Mobile/ut/Locations. Response for preflight has invalid HTTP status code 405"....

After hiting in browser i'm getting these results

Status Code: 200 OK
Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS
Access-Control-Allow-Origin: *
Cache-Control: no-cache
Content-Length: 32409
Content-Type: application/json
Date: Tue, 21 Jun 2016 06:34:32 GMT
Expires: -1
Pragma: no-cache
Server: Microsoft-IIS/7.5
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
access-control-allow-headers: Accept, Origin, Content-Type, Authorization

What will be the cause...Please Help....Thank You

iOS issue

Hi,

I've been trying to use this plugin for iOS and android, the android works fine, but the iOS won't work, when the apps is running, it's only showing a page with encrypted string on it. I don't know how to trace so I couldn't really know where is the problem.

I'm using cordova 5.4.1 iOS 3.9.2 and com.telerik.plugins.wkwebview plugin

not working with phone gap build

I use below version of cordova

I am trying to add it in config.xml like below
<gap:plugin name="cordova-plugin-crypt-file" source="npm"/>
and like below

its build succeeded but no files encrypted

HTML not decrypted after reload

Hi,

I have detected that when I execute this in Javascript:

window.location.reload()

After reloading the raw html file (encrypted) gets displayed instead of the decrypted version. I managed to work around the problem by doing this instead:

window.location = window.location.href.replace(/#.*/, '');

I believe the problem might be isCryptFiles. It doesn't take into account that the URI might have a fragment identifier and it doesn't look like this situation is handled anywhere else.

CRYPT_KEY

Hi, I've a question..

How is generated the CRYPT_KEY ? It's always "" ? or a random value?

Thanks!

Having issue with Cordova 6.2.0 on IOS platform

Hello Tkyaji,

Its is a very nice plugin, thanks for the best plugin for security.
ISSUE:
I tried this plugin in android and its working awesome. But I have an issue on IOS platform. I am using ionic framework with Cordova 6.2.0 for my application. White screen comes when application launch and nothing happened after that. Plugin files .h and .m files are executed but files are not encrypted in build.

can you please help me with it.

Thanks in advance.
Bhumika

CordovaResourceApi.OpenForReadResult issue with Unencrypted URI

I am trying to open my iFrame URL but it is displaying on HTML in browser, unable to figure out how to show proper iFrame within the browser while using crypt-file. Source enclosed below.

@OverRide
public CordovaResourceApi.OpenForReadResult handleOpenForRead(Uri uri)
throws IOException {
String uriStr = this.tofileUri(this.launchUri);

    Log.d("TAG", "URL "+uriStr);

    CordovaResourceApi.OpenForReadResult readResult = this.webView
            .getResourceApi().openForRead(Uri.parse(uriStr), true);

    Log.d("TAG", "Check Encryption "+isCryptFiles(uriStr));

    if (isCryptFiles(uriStr) == false) {

            Log.d("TAG", "Check Encryption inside "+isCryptFiles(uriStr));

            //return readResult;
    } else if (isCryptFiles(uriStr) == true) {

        BufferedReader br = new BufferedReader(new InputStreamReader(
                readResult.inputStream));
        StringBuilder strb = new StringBuilder();
        String line = null;
        while ((line = br.readLine()) != null) {
            strb.append(line);
        }
        br.close();

        byte[] bytes = Base64.decode(strb.toString(), Base64.DEFAULT);

        LOG.d(TAG, "decrypt: " + uriStr);
        ByteArrayInputStream byteInputStream = null;
        try {
            SecretKey skey = new SecretKeySpec(CRYPT_KEY.getBytes("UTF-8"),
                    "AES");
            Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
            cipher.init(Cipher.DECRYPT_MODE, skey, new IvParameterSpec(
                    CRYPT_IV.getBytes("UTF-8")));

            ByteArrayOutputStream bos = new ByteArrayOutputStream();
            bos.write(cipher.doFinal(bytes));
            byteInputStream = new ByteArrayInputStream(bos.toByteArray());

        } catch (Exception ex) {
            LOG.e(TAG, ex.getMessage());
        }

        Log.d("TAG","Encryption possible");

        return new CordovaResourceApi.OpenForReadResult(readResult.uri,
                        byteInputStream, readResult.mimeType, readResult.length,
                        readResult.assetFd);


    }

    Log.d("TAG", "Check Encryption outside "+isCryptFiles(uriStr));

    return readResult;

}

Using ionic.Platform.ready to get device uuid doesn't run after installing the cordova-plugin-crypt-file plugin

I have been trying to obtain my device uuid for some 2 days now still cant find away through, The code works fine without the plugin and i get the uuid, but once i install it simply doesnt show.
I have isolated the problem to this function ionic.Platform.ready() as it is not executed.Kindly help out solve this issue.

Here is the sample code:

.run(function($ionicPlatform, $localstorage) {  
    $ionicPlatform.ready(function() {
        if (window.cordova && window.cordova.plugins.Keyboard) {
            cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
        }
        if (window.StatusBar) {
            StatusBar.styleDefault();
        }
        var device = ionic.Platform.device();
        $localstorage.set('deviceIDs', device.uuid);  
    })  ;
})

how to hide CRYPT_KEY

Hi I implemented this successfully. But when I decompile my apps than I found key in com/tkyaji/cordova/DecryptResource.java just like

public class DecryptResource extends CordovaPlugin {
private static final String CRYPT_IV = "2f4p6XIsww3+5kBG";
private static final String CRYPT_KEY = "TA5GpZAipc1ReX5BEZEd9FnQTVB7Zp6w";
private static final String[] EXCLUDE_FILES;
private static final String[] INCLUDE_FILES;
private static final String TAG = "DecryptResource";

what should I do to hide key also.

How to add plugin(cordova-plugin-crypt-file) manually?

Hi Team,

My application is IBM mobile first hybrid application. I want to use this plugin for obfuscation of my js/css/html. Where should i put the after_prepare (placed under hooks) file in my application. I am not able to add the plugin in my application. Please let me know if you can help

CORS issue on Android

Hi,

on Android I am facing the following problem:
No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost' is therefore not allowed access.

I have already added localhost to whitelisting, but the issue persists.
I am using Cordova 5.4.1
on Android Nexus 5
Android version 6.0 and 5.1.1

Any help would be appreciated.

Best regards

i know the reason for CORS or HTTP 404 and need help

Dear all and developer for the tools

this tool is very helpful for me and just works fine in ios but the android not ver well

i saw all the issue here and all of them like my problem (ajax call failed , CORS ..etc)

and i used all the CORS in the server and client side.

i figured out the the tool send OPTION request to the server instead of GET or POST

i didn't used OPTION ever so how come it's arrive with this request

please see my apache logs after ajax calls

5.156.xxxx- - [01/Jul/2016:05:48:53 -0700] "OPTIONS /sabaak-server/sql_codes_v2_2.php/getAllLaboor HTTP/1.1" 404 384 "http://localhost/google_test.html" "Mozilla/5.0 (Linux; Android 4.4.4; SM-J110H Build/KTU84P) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/33.0.0.0 Mobile Safari/537.36"

this ajax call i used GET no OPTIONS in javascript and that's why it's return HTTP 404 because they aren't any api using OPTIONS.

so can you please (tkyaji) help us in this problem.

i stop my application in play store just waiting for your help :(

Exclude Extensions

How to exclude extension to ecrypt?

Example: I just want to encrypt ".js"

I tried in but not work
private static final String[] CRYPT_FILES = {
".js",
};

Not Decrypting Images

Thanks for this Plugin it works like Charm on codorva 6.4 but i have an issue with other extension like (.png , .jpg , .mp3 , .mpeg). these extensions are encrypting properly but not been able to decrypt at run-time or app-ready.

I want to know if the plugin supports this formats or needs to be modified for it to handle it, and if need be please kindly do cos you are simply the best to provide this useful protector for cordova.

Thanks

Encrypt plugin fail

Is possible to no crypt cordova plugins? Only my code no 3rd parties plugins?
I'm getting some issues with that

Not working on iOS 8.14 and iOS 9 beta

Great plugin, thank you very much. It works on Android (Just tested it on 5.1.1) very well, but on iOS it is not decrypting the js file. It just shows the encrypted code. I tried it with iOS 8.14, iOS 9 beta, XCode 6.4 and XCode 7 beta 5.

I got no error messages.

Easy to decrypt

Hi, first of all thank you for making this work public, I think this plugin would be really useful to make disassembling a little bit harder.
However, it stores the key and the IV inside the plugin code itself, any hacker with a disassembler would have access to it.
Wouldn't be nice if we could generate the keys in runtime (e.g. first use), store it on the device's secure storage and then retrieve the keys from it? Are you guys planning something like that?

(android) not working well with other plugin

Just realise that this plugin will replace url scheme file:///android_aset/www into http://localhost/ for the android. This work just fine when the apps is pure javascript that will run completely in the browser. But when I combine this plugin with another plugin such as camera and geolocation, the problem shows up. The plugin seems unable to call the cordova API as it's using nodejs like require mechanism, so it will failed when the url is converted into http://localhost/

I found a workaround with this issue by partially encrypt the source, only the javascript of my apps that need to be encrypted. Just modify the file searching function of file to be encrypted, and change the source link of the url of the encrypted file from relative path to http://localhost/ (bower_components/js -> http://localhost/bower_components/js)

The downside is that I have to create separate project for the android and ios with this method, and if I want to encrypt the .html I have to refactor all the page link to include http://localhost schema , and I can't encrypt the index.html as it will convert everything into http://localhost schema (as the original plugin method)

I wish there will be a better solution and patch to this issue for the future. Anyway this plugin is very useful and thank you.

Error when build application for Android

This error when I build application for Android.

TypeError: undefined is not a function
at plugins\cordova-plugin-crypt-file\hooks\after_prepare.js
:92:30
at Array.map (native)
at module.exports (plugins\cordova-plugin-crypt-file\hooks
after_prepare.js:80:19)
at runScriptViaModuleLoader (AppData\Roaming\npm\node_modul
es\cordova\node_modules\cordova-lib\src\hooks\HooksRunner.js:152:18)
at runScript (AppData\Roaming\npm\node_modules\cordova\node
_modules\cordova-lib\src\hooks\HooksRunner.js:130:16)
at AppData\Roaming\npm\node_modules\cordova\node_modules\co
rdova-lib\src\hooks\HooksRunner.js:115:20
at _fulfilled (AppData\Roaming\npm\node_modules\cordova\nod
e_modules\q\q.js:787:54)
at self.promiseDispatch.done (AppData\Roaming\npm\node_modu
les\cordova\node_modules\q\q.js:816:30)
at Promise.promise.promiseDispatch (AppData\Roaming\npm\nod
e_modules\cordova\node_modules\q\q.js:749:13)
at AppData\Roaming\npm\node_modules\cordova\node_modules\q
q.js:810:14

Doesnt work with Phonegap build

any support for PGB? i am using latest version of this plugin along with PGB with cli version 6.5.0 but none of the files are getting encrypted..

database apk

i have a problem with file .db. it isn't loading the file when start the app

Problem with CORS

I/chromium(24780): [INFO:CONSOLE(0)] "XMLHttpRequest cannot load http://backend:11000/login. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost' is therefor e not allowed access. The response had HTTP status code 404.", source: http://localhost/index.html#/ (0)

Without plugin everything working fine. Access-Control-Allow-Origin is present in response header, i've checked that from two devices & pc. Seems like config.xml is not working like it should or some other stuff..

Files not decrypted when app launched. I could see my cordova project file got encrypted but could not launch the application

Hi tkyaji,

Thanks for this awesome plugin, much needed for hybrid apps!

I am using cordova-plugin-crypt-file in my project. I have installed the plugin and built cordova android project.
When I checked the source code after building it, the files got successfully encrypted.

But when I run the project (launch on Android device), it gives error of index.html not found.

Please suggest if I am missing on any other configuration or anything needs to be upgraded.
Using cordova version 5.4.0
Ionic version 1.7.10

Please help!!!

This plugin breaks internal links

It looks like this plugin break the internal link, with ionic framework.

How to reproduce it:

ionic start myApp blank
cd myApp
cordova plugin add cordova-plugin-crypt-file
# In www/index.html add two links
#                <a href="x1.html">X1</a>
#                <a href="x2.html">X2</a>
# add the x1.html and x2 two file in www folder
ionic platform add android
#add key sign file if needed
ionic build --release

Then install the apk, the above two links do not work. When you click there is no response. no error message either. remove plugin things work perfectly.

ENV
OS Debian GNU/Linux 8
node 4.4.4
cordova 6.1.1
ionic 1.7.16
java 1.8.0_25
Android 4.4.4 x86 in virtualbox

Can you please send the code to encrypt file

Hi,

I am using ionic framework to build a mobile app. I want to encrypt one of my file. Can you please tell me how to call the plugin to encrypt it. Or just installation of the plugin is enough?

Plugin version info

Plugin version info in plugin.xml is 0.0.1 and package.json is 1.2.1 - which can be a little confusing when identifying which version the plugin is at.

Plugin is brilliant!

Feature request

Hi,

that plugin is really great!

During my debugging with my Android, it get's a bit annoying if that plugin is installed.

So my request is:
Is it possible to turn of the cryptonize part if the app is build with --debug ?

Or the way round: Only activate the crypto-plugin if the app is build with --release ?

Sven

Your hooks are not uptodate

I got the message
The module "ConfigParser" has been factored into "cordova-common". Consider update your plugin hooks.

It seems that you hook on line 69 is not correct anymore.

Build fail

Hello,
I'm trying to add the plugin in my Android Cordova project but I got this build fail error:

BUILD FAILED

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':transformClassesWithMultidexlistForArmv7Debug'.

java.lang.UnsupportedOperationException (no error message)

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

Could you please help me?

Fail decryption file after run on device

I build app on cocoon.io -->my app.apk is Encrypt all file I want to. When install app to device, after splash screen --> app not run and display white screen with unknown text.
Somebody know how to fix this ?
-Project type: Construct 2 r248
-Engine: webview
-Cocoonversion: latest.
-Plugin: cocoon googleplay, cocoon native share, admob native.

Header fileld problem when i use this crypt plugin

Hello, when I install this plugin I got this error in some http request
Request header field sessionIdsTT is not allowed by Access-Control-Allow-Headers.

I use Ionic and AngularJS.

Any idea to fix that? Only Happen in Android, in iOS works well.

Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.