disusered / cordova-safe Goto Github PK
View Code? Open in Web Editor NEWFile encryption for Cordova.
License: MIT License
File encryption for Cordova.
License: MIT License
This is a serious concern since its doesn't allow the app to run keep getting error any idea when it will get solved
Safe.java:120: error: cannot find symbol
CRYPTO = new Crypto(new SharedPrefsBackedKeyChain(CONTEXT), new SystemNativeCryptoLibrary());
^
symbol: class SharedPrefsBackedKeyChain
location: class Safe
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
2 errors
FAILURE: Build failed with an exception.
Compilation failed; see the compiler error output for details.
How to solve this
Error:
"THREAD WARNING: exec() call to Safe.encrypt blocked the main thread for 20ms. Plugin should use CordovaInterface.getThreadPool()."
Cordova version 6.4.0
Do not call callback success or error.
Hope this project is till maintained I'm always getting an error while trying to encrypt the file
HI i am using this plugin in my ionic 3 project but it is showing plugin not installed
ERROR Error: Uncaught (in promise): plugin_not_installed
I want to encrypt my files in the server and after downloaded with my ionic app decrypt it with this plugin.
Is there a tool in windows that encrypts the files in the format of this plugin?
Seems cordova can't locate the com.facebook.crypto lib. I'm using cordova-safe in a meteor app so this may look a little different than a normal cordova debug output, but under the hood it really is just cordova. com.facebook.crypto.* java lib isn't listed as a dependency. Should it be? am I missing something else? Thank you! error below
[buildconfig] Generating BuildConfig class.
-pre-compile:
[echo] Set jars path to: /media/Storage/emocha/platform-midot-mobile/app/.meteor/local/cordova-build/platforms/android/CordovaLib/ant-build/classes.jar
-compile:
[javac] Compiling 31 source files to /media/Storage/emocha/platform-midot-mobile/app/.meteor/local/cordova-build/platforms/android/ant-build/classes
[javac] /media/Storage/emocha/platform-midot-mobile/app/.meteor/local/cordova-build/platforms/android/src/com/disusered/Safe.java:21: error: package com.facebook.crypto does not exist
[javac] import com.facebook.crypto.Crypto;
[javac] ^
[javac] /media/Storage/emocha/platform-midot-mobile/app/.meteor/local/cordova-build/platforms/android/src/com/disusered/Safe.java:22: error: package com.facebook.crypto does not exist
[javac] import com.facebook.crypto.Entity;
[javac] ^
[javac] /media/Storage/emocha/platform-midot-mobile/app/.meteor/local/cordova-build/platforms/android/src/com/disusered/Safe.java:23: error: package com.facebook.crypto.exception does not exist
[javac] import com.facebook.crypto.exception.CryptoInitializationException;
[javac] ^
[javac] /media/Storage/emocha/platform-midot-mobile/app/.meteor/local/cordova-build/platforms/android/src/com/disusered/Safe.java:24: error: package com.facebook.crypto.exception does not exist
[javac] import com.facebook.crypto.exception.KeyChainException;
[javac] ^
[javac] /media/Storage/emocha/platform-midot-mobile/app/.meteor/local/cordova-build/platforms/android/src/com/disusered/Safe.java:25: error: package com.facebook.android.crypto.keychain does not exist
[javac] import com.facebook.android.crypto.keychain.SharedPrefsBackedKeyChain;
[javac] ^
[javac] /media/Storage/emocha/platform-midot-mobile/app/.meteor/local/cordova-build/platforms/android/src/com/disusered/Safe.java:26: error: package com.facebook.crypto.util does not exist
[javac] import com.facebook.crypto.util.SystemNativeCryptoLibrary;
[javac] ^
[javac] /media/Storage/emocha/platform-midot-mobile/app/.meteor/local/cordova-build/platforms/android/src/com/disusered/Safe.java:37: error: cannot find symbol
[javac] private Crypto CRYPTO;
[javac] ^
[javac] symbol: class Crypto
[javac] location: class Safe
[javac] /media/Storage/emocha/platform-midot-mobile/app/.meteor/local/cordova-build/platforms/android/src/com/disusered/Safe.java:38: error: cannot find symbol
[javac] private Entity ENTITY;
[javac] ^
[javac] symbol: class Entity
[javac] location: class Safe
[javac] /media/Storage/emocha/platform-midot-mobile/app/.meteor/local/cordova-build/platforms/android/src/com/disusered/Safe.java:96: error: cannot find symbol
[javac] } catch (CryptoInitializationException e) {
[javac] ^
[javac] symbol: class CryptoInitializationException
[javac] location: class Safe
[javac] /media/Storage/emocha/platform-midot-mobile/app/.meteor/local/cordova-build/platforms/android/src/com/disusered/Safe.java:98: error: cannot find symbol
[javac] } catch (KeyChainException e) {
[javac] ^
[javac] symbol: class KeyChainException
[javac] location: class Safe
[javac] /media/Storage/emocha/platform-midot-mobile/app/.meteor/local/cordova-build/platforms/android/src/com/disusered/Safe.java:111: error: cannot find symbol
[javac] ENTITY = new Entity(password);
[javac] ^
[javac] symbol: class Entity
[javac] location: class Safe
[javac] /media/Storage/emocha/platform-midot-mobile/app/.meteor/local/cordova-build/platforms/android/src/com/disusered/Safe.java:116: error: cannot find symbol
[javac] CRYPTO = new Crypto(new SharedPrefsBackedKeyChain(CONTEXT), new SystemNativeCryptoLibrary());
[javac] ^
[javac] symbol: class Crypto
[javac] location: class Safe
[javac] /media/Storage/emocha/platform-midot-mobile/app/.meteor/local/cordova-build/platforms/android/src/com/disusered/Safe.java:116: error: cannot find symbol
[javac] CRYPTO = new Crypto(new SharedPrefsBackedKeyChain(CONTEXT), new SystemNativeCryptoLibrary());
[javac] ^
[javac] symbol: class SharedPrefsBackedKeyChain
[javac] location: class Safe
[javac] /media/Storage/emocha/platform-midot-mobile/app/.meteor/local/cordova-build/platforms/android/src/com/disusered/Safe.java:116: error: cannot find symbol
[javac] CRYPTO = new Crypto(new SharedPrefsBackedKeyChain(CONTEXT), new SystemNativeCryptoLibrary());
[javac] ^
[javac] symbol: class SystemNativeCryptoLibrary
[javac] location: class Safe
[javac] Note: Some input files use or override a deprecated API.
[javac] Note: Recompile with -Xlint:deprecation for details.
[javac] Note: Some input files use unchecked or unsafe operations.
[javac] Note: Recompile with -Xlint:unchecked for details.
[javac] 14 errors
Command finished with error code 8: /media/Storage/emocha/platform-midot-mobile/app/.meteor/local/cordova-build/platforms/android/cordova/run --device
ERROR running one or more of the platforms: Error: /media/Storage/emocha/platform-midot-mobile/app/.meteor/local/cordova-build/platforms/android/cordova/run: Command failed with exit code 8
You may not have the required environment or OS to run this project
BUILD FAILED
/Users/bgrayburn/.meteor/android_bundle/android-sdk/tools/ant/build.xml:716: The following error occurred while executing this line:
/Users/bgrayburn/.meteor/android_bundle/android-sdk/tools/ant/build.xml:730: Compile failed; see the compiler error output for details.
Total time: 3 seconds
/media/Storage/emocha/platform-midot-mobile/app/.meteor/local/cordova-build/platforms/android/cordova/node_modules/q/q.js:126
throw e;
^
Error code 1 for command: ant with args: debug,-f,/media/Storage/emocha/platform-midot-mobile/app/.meteor/local/cordova-build/platforms/android/build.xml,-Dout.dir=ant-build,-Dgen.absolute.dir=ant-gen
I have this app where I take picture or select it from gallery then move it into file-system , save the imgpath for the image into sqlite db and display it, I'm trying to encrypt the imgPath for the image which is saved on ccordova.file.datadirectory ,but I keep getting "Error with cryptographic operation".
any help would be appreciated
var db = null;
angular.module('starter', ['ionic', 'ngCordova'])
.run(function($ionicPlatform, $cordovaSQLite) {
$ionicPlatform.ready(function() {
try {
db = $cordovaSQLite.openDB({
name: "my.db",
location: 'default'
});
$cordovaSQLite.execute(db,"CREATE TABLE IF NOT EXISTS imageTable " + "(id integer primary key, image text)");
} catch (e) {
alert(e);
} finally { }
if (window.cordova && window.cordova.plugins.Keyboard) {
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
cordova.plugins.Keyboard.disableScroll(true);
}
if (window.StatusBar) {
StatusBar.styleDefault();
}
});
})
.controller('ImageCtrl', function($scope, $rootScope, $state, $stateParams, $cordovaDevice, $cordovaFile, $ionicActionSheet, $cordovaCamera, $cordovaFile, $cordovaDevice, $ionicPopup, $cordovaActionSheet, $cordovaSQLite, $interval) {
var imagesP = [];
//$scope.images = [];
$scope.showAlert = function(title, msg) {
var alertPopup = $ionicPopup.alert({
title: title,
template: msg
});
};
$scope.loadImage = function() {
var options = {
title: 'Select Receipts Image ',
buttonLabels: ['Gallery', 'Take photo', 'File System'],
addCancelButtonWithLabel: 'Cancel',
androidEnableCancelButton: true,
};
$cordovaActionSheet.show(options).then(function(btnIndex) {
var type = null;
if (btnIndex === 1) {
type = Camera.PictureSourceType.PHOTOLIBRARY;
} else if (btnIndex === 2) {
type = Camera.PictureSourceType.CAMERA;
}
if (type !== null) {
$scope.selectPicture(type);
}
});
}
// Take image with the camera or from library and store it inside the app folder
// Image will not be saved to users Library.
$scope.selectPicture = function(sourceType) {
var options = {
quality: 75,
destinationType: Camera.DestinationType.FILE_URI,
sourceType: sourceType,
allowEdit: true,
encodingType: Camera.EncodingType.JPEG,
correctOrientation: true,
targetWidth: 800,
targetHeight: 800,
popoverOptions: CameraPopoverOptions, // for IOS and IPAD
saveToPhotoAlbum: false
};
$cordovaCamera.getPicture(options).then(function(imagePath) {
// Grab the file name of the photo in the temporary directory
var currentName = imagePath.replace(/^.*[\\\/]/, '');
// alert(currentName);
//Create a new name for the photo to avoid duplication
var d = new Date(),
n = d.getTime(),
newFileName = n + ".jpg";
//alert(newFileName);
// If you are trying to load image from the gallery on Android we need special treatment!
if ($cordovaDevice.getPlatform() == 'Android' && sourceType === Camera.PictureSourceType.PHOTOLIBRARY) {
window.FilePath.resolveNativePath(imagePath, function(entry) {
window.resolveLocalFileSystemURL(entry, success, fail);
function fail(e) {
console.error('Error: ', e);
}
function success(fileEntry) {
var namePath = fileEntry.nativeURL.substr(0, fileEntry.nativeURL.lastIndexOf('/') + 1);
// Only copy because of access rights
$cordovaFile.copyFile(namePath, fileEntry.name, cordova.file.dataDirectory, newFileName).then(function(success) {
// $scope.image = newFileName;
var imgPath = cordova.file.dataDirectory + newFileName;
$scope.add(imgPath);
$scope.encryptFile(imgPath);
}, function(error) {
$scope.showAlert('Error', error.exception);
});
// alert( fileEntry.nativeURL);
};
});
} else {
var namePath = imagePath.substr(0, imagePath.lastIndexOf('/') + 1);
// Move the file to permanent storage
$cordovaFile.moveFile(namePath, currentName, cordova.file.dataDirectory, newFileName).then(function(success) {
// $scope.image = newFileName;
//$scope.images.push(newFileName);
var imgPath = cordova.file.dataDirectory + newFileName;
$scope.add(imgPath);
}, function(error) {
$scope.showAlert('Error', error.exception);
});
}
},
function(err) {
// Not always an error, maybe cancel was pressed...
})
};
$scope.add = function(path) {
if (imagesP != null) {
$cordovaSQLite.execute(db, "INSERT INTO imageTable (images) VALUES(?)", [path] );
}
alert("Inserted.");
},
function(e) {
alert(e);
};
$scope.encryptFile = function(file){
var safe = cordova.plugins.disusered.safe,
key = 'someKeyABC';
function success(encryptedFile) {
console.log('Encrypted file: ' + encryptedFile);
}
function error() {
console.log('Error with cryptographic operation');
}
safe.encrypt(file, key, success, error);
}
$scope.ShowAllData = function() {
$scope.images = [];
$cordovaSQLite.execute(db,"SELECT images FROM imageTable").then(function(res) {
if (res.rows.length > 0) {
for (var i = 0; i < res.rows.length; i++) {
$scope.images.push({
id: res.rows.item(i).id,
image: res.rows.item(i).images
});
}
}
}, function(error) {
alert(error);
} );
}
Anyone else seen this? Using Xcode 9.2
Ionic project
/app/Plugins/cordova-safe/RNCryptor.m:31:12: error: conflicting types for 'SecRandomCopyBytes' extern int SecRandomCopyBytes(SecRandomRef rnd, size_t count, uint8_t *bytes) __attribute__((weak_import)); ^ In module 'Security' imported from /app/Plugins/cordova-safe/RNCryptor.h:30: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS11.2.sdk/System/Library/Frameworks/Security.framework/Headers/SecRandom.h:59:5: note: previous declaration is here int SecRandomCopyBytes(SecRandomRef __nullable rnd, size_t count, void *bytes) ^ /app/Plugins/cordova-safe/RNCryptor.m:361:7: warning: comparison of function 'SecRandomCopyBytes' not equal to a null pointer is always true [-Wtautological-pointer-compare] if (SecRandomCopyBytes != NULL) { ^~~~~~~~~~~~~~~~~~ ~~~~ /app/Plugins/cordova-safe/RNCryptor.m:361:7: note: prefix with the address-of operator to silence this warning if (SecRandomCopyBytes != NULL) { ^ &
After install plugin Ionic 3 app cannot run. it getting error
Error: cmd: Command failed with exit code 1 Error output:
G:\Android\TestProject\platforms\android\src\com\disusered\Safe.java:26: error: package com.facebook.android.crypto.keychain does not exist
import com.facebook.android.crypto.keychain.SharedPrefsBackedKeyChain;
^
G:\Android\TestProject\platforms\android\src\com\disusered\Safe.java:120: error: cannot find symbol
CRYPTO = new Crypto(new SharedPrefsBackedKeyChain(CONTEXT), new SystemNativeCryptoLibrary());
^
symbol: class SharedPrefsBackedKeyChain
location: class Safe
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: G:\Android\TestProject\platforms\android\src\org\apache\cordova\file\AssetFilesystem.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
2 errors
FAILURE: Build failed with an exception.
Compilation failed; see the compiler error output for details.
While encrypt and decrypt operations appear to fully succeed, the success callbacks do not appear to be getting fired when using recent versions of Cordova (repro'd on 5.4.1 and 6.0.0) when using example code in readme.
Hi, I am trying to install this plugin with Ionic but I get this error when I try to build the project just by instaling the plugin.
Error is:
`C:\Users\Zel\Desktop\a\platforms\android\src\com\disusered\Safe.java:120: error: cannot find symbol
CRYPTO = new Crypto(new SharedPrefsBackedKeyChain(CONTEXT), new SystemNativeCryptoLibrary());
^
symbol: class SharedPrefsBackedKeyChain
location: class Safe
Note: Some input files use or override a deprecated API.
:compileDebugJavaWithJavac FAILED
Note: Recompile with -Xlint:deprecation for details.
2 errors
FAILURE: Build failed with an exception.
Compilation failed; see the compiler error output for details.
BUILD FAILED
Total time: 11.002 secs
(node:14276) UnhandledPromiseRejectionWarning: Error: cmd: Command failed with exit code 1 Error output:
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
C:\Users\Zel\Desktop\a\platforms\android\src\com\disusered\Safe.java:26: error: package com.facebook.android.crypto.keychain does not exist
import com.facebook.android.crypto.keychain.SharedPrefsBackedKeyChain;
^
C:\Users\Zel\Desktop\a\platforms\android\src\com\disusered\Safe.java:120: error: cannot find symbol
CRYPTO = new Crypto(new SharedPrefsBackedKeyChain(CONTEXT), new SystemNativeCryptoLibrary());
^
symbol: class SharedPrefsBackedKeyChain
location: class Safe
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
2 errors
FAILURE: Build failed with an exception.
Compilation failed; see the compiler error output for details.
After hours of investigation, I have come to the conclusion that the cryptsetup error lies with cordova-safe.
I followed the official documentation very pedantic.
It still did not work! I even started 2 new projects from Scratch!
Just to check if I made a mistake or if something was wrong with npm.
Unfortunately, it is definitely the plugin which does not work anymore!
I really hope very much that cordova-safe is further developed!
Detailed information: https://stackoverflow.com/questions/44969832/is-cordova-safe-still-working-with-ionic3
Native: tried calling FileEncryption.encrypt, but the FileEncryption plugin is not installed.
vendor.js:56747 Install the FileEncryption plugin: 'ionic cordova plugin add cordova-safe'
plugin is install and used according to https://ionicframework.com/docs/native/file-encryption/
and nobody fixed this issue.
Hi,
I added the plugin to my cordova project and it is shown in the plugin directory.
But I get this error when trying to compile the project.
When I type "cordova plugins" in the project directory I get the following output:
cordova-safe 1.0.6 "Safe"
org.apache.cordova.camera 0.3.6 "Camera"
org.apache.cordova.device 0.3.0 "Device"
org.apache.cordova.file 1.3.3 "File"
org.apache.cordova.file-transfer 0.4.8 "File Transfer"
org.apache.cordova.geolocation 0.3.12 "Geolocation"
org.apache.cordova.network-information 0.2.15 "Network Information"
org.apache.cordova.splashscreen 1.0.0 "Splashscreen"
Where is the error?
Thx, Martin
this Error keep show up every time I had to build IOS on cordova 6.2.0 and IOS 4.1.1
When attempting to build iOS with Cordova 6.0.0 with this plugin installed an error is thrown stating that "Cordova/NSData+Base64.h" is not found originating from safe.h.
When using Cordova 5.4.1 in the iOS simulator, the plugin always throws an error of "null" since fileExists always resolves to null in the main crypto method in safe.m.
i try to install this plugin, but ionic say: "FileEncryption plugin is not installed."
But I installed with:
$ ionic cordova plugin add cordova-safe
$ npm install --save @ionic-native/file-encryption
And I use it as following:
import { Component } from '@angular/core';
import { NavController, Platform } from 'ionic-angular';
import { FileEncryption } from '@ionic-native/file-encryption';
@Component({
selector: 'page-home',
templateUrl: 'home.html'
})
export class HomePage {
constructor(public navCtrl: NavController,
private fileEncryption: FileEncryption,
public platform: Platform) {
this.platform.ready().then(() => {
console.log('Platform ready!!!');
this.fileEncryption.decrypt('assets/json/secret.json', 'secretKey');
this.fileEncryption.encrypt('assets/json/secret.json', 'secretKey');
});
}
}
Native: tried calling FileEncryption.decrypt, but the FileEncryption plugin is not installed.
Install the FileEncryption plugin: 'ionic cordova plugin add cordova-safe'
This is my Configuration:
cli packages: (C:\Users\username.npm-packages\node_modules)
@ionic/cli-utils : 1.19.2
ionic (Ionic CLI) : 3.20.0
global packages:
cordova (Cordova CLI) : 7.1.0
local packages:
@ionic/app-scripts : 3.1.8
Cordova Platforms : android 6.3.0
Ionic Framework : ionic-angular 3.9.2
System:
Node : v6.9.4
npm : 5.6.0
OS : Windows 10
Environment Variables:
ANDROID_HOME : not set
Misc:
backend : pro
Tried plugin with cordova-android 7.1.0 and cordova 8.0.0.
Getting this error at compile time:
\platforms\android\app\src\main\java\com\disusered\Safe.java:26: error: package com.facebook.android.crypto.keychain does not exist
import com.facebook.android.crypto.keychain.SharedPrefsBackedKeyChain;
^
\platforms\android\app\src\main\java\com\disusered\Safe.java:120: error: cannot find symbol
CRYPTO = new Crypto(new SharedPrefsBackedKeyChain(CONTEXT), new SystemNativeCryptoLibrary());
^
symbol: class SharedPrefsBackedKeyChain
location: class Safe
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
2 errors
FAILURE: Build failed with an exception.
Compilation failed; see the compiler error output for details.
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
Get more help at https://help.gradle.org
BUILD FAILED in 53s
(node:17028) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with
a non-zero exit code.
Hi, I am trying out the plugin (using your example in the readme), but I keep getting this error in adb logs:
W/System.err(30861): java.lang.ClassNotFoundException: com.disusered.Safe
W/System.err(30861): at java.lang.Class.classForName(Native Method)
W/System.err(30861): at java.lang.Class.forName(Class.java:308)
W/System.err(30861): at java.lang.Class.forName(Class.java:272)
W/System.err(30861): at org.apache.cordova.PluginManager.instantiatePlugin(PluginManager.java:487)
W/System.err(30861): at org.apache.cordova.PluginManager.getPlugin(PluginManager.java:167)
W/System.err(30861): at org.apache.cordova.PluginManager.exec(PluginManager.java:120)
W/System.err(30861): at org.apache.cordova.CordovaBridge.jsExec(CordovaBridge.java:59)
W/System.err(30861): at org.apache.cordova.engine.SystemExposedJsApi.exec(SystemExposedJsApi.java:41)
W/System.err(30861): at org.chromium.base.SystemMessageHandler.nativeDoRunLoopOnce(Native Method)
W/System.err(30861): at org.chromium.base.SystemMessageHandler.handleMessage(SystemMessageHandler.java:53)
W/System.err(30861): at android.os.Handler.dispatchMessage(Handler.java:102)
W/System.err(30861): at android.os.Looper.loop(Looper.java:135)
W/System.err(30861): at android.os.HandlerThread.run(HandlerThread.java:61)
W/System.err(30861): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.disusered.Safe" on path: DexPathList[[zip file "/data/app/io.cordova.hellocordova-2/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
W/System.err(30861): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
W/System.err(30861): at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
W/System.err(30861): at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
W/System.err(30861): ... 13 more
W/System.err(30861): Suppressed: java.lang.ClassNotFoundException: com.disusered.Safe
W/System.err(30861): at java.lang.Class.classForName(Native Method)
W/System.err(30861): at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
W/System.err(30861): at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
W/System.err(30861): at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
W/System.err(30861): ... 14 more
W/System.err(30861): Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available
I/System.out(30861): Error adding plugin com.disusered.Safe.
W/System.err(30861): java.lang.NullPointerException: Attempt to invoke virtual method 'void org.apache.cordova.CordovaPlugin.privateInitialize(java.lang.String, org.apache.cordova.CordovaInterface, org.apache.cordova.CordovaWebView, org.apache.cordova.CordovaPreferences)' on a null object reference
W/System.err(30861): at org.apache.cordova.PluginManager.getPlugin(PluginManager.java:169)
W/System.err(30861): at org.apache.cordova.PluginManager.exec(PluginManager.java:120)
W/System.err(30861): at org.apache.cordova.CordovaBridge.jsExec(CordovaBridge.java:59)
W/System.err(30861): at org.apache.cordova.engine.SystemExposedJsApi.exec(SystemExposedJsApi.java:41)
W/System.err(30861): at org.chromium.base.SystemMessageHandler.nativeDoRunLoopOnce(Native Method)
W/System.err(30861): at org.chromium.base.SystemMessageHandler.handleMessage(SystemMessageHandler.java:53)
W/System.err(30861): at android.os.Handler.dispatchMessage(Handler.java:102)
W/System.err(30861): at android.os.Looper.loop(Looper.java:135)
W/System.err(30861): at android.os.HandlerThread.run(HandlerThread.java:61)
I use the cordova cli, and tried removing and readding the plugin as well as removing and readding the android platform, still no luck. I ran the app on the emulator as well as my android device (both running 5.1).
Hi Guys,
After installing plugin in my cordova app, its giving me "Uncaught TypeError: Cannot read property 'disusered' of undefined" on "var safe = cordova.plugins.disusered.safe".
plugin is installed properly, still getting this error.
Please provide some information about it, how to solve this error
When I try to decrypt pdf file I got this error
Hi,
Looking over the src folder I noticed that the code for Android and iOS is licensed as GPL2, however the LICENSE file in the root is MIT. Is that intentional?
Regards
Phil
Neither of the callbacks provided to safe.encrypt
are getting called.
Info:
OS: Windows 7
Device:
OnePlus One
Android version: 5.0.2
$ cordova --version
5.1.1
$ cordova plugins list
cordova-plugin-file 2.1.0 "File"
cordova-plugin-whitelist 1.0.0 "Whitelist"
cordova-safe 1.1.1 "Safe"
Code to reproduce the issue:
var
onDeviceReady = function () {
// create a file in the persistent storage
window.requestFileSystem(window.PERSISTENT, 5 * 1024 * 1024, onInitFs, onError);
},
onError = function (e) {
console.error('Error:', e, e.code);
},
onInitFs = function (fs) {
console.log('Opened file system: ' + fs.name);
fs.root.getFile('userData.json', {create: true, exclusive: false}, function (fileEntry) {
fileEntry.createWriter(function (fileWriter) {
fileWriter.onwriteend = onFileWriteComplete;
fileWriter.onerror = onError;
// Write a file containing some test data
fileWriter.write(new Blob(
[JSON.stringify({some: 'data'})],
{type: 'application/json'})
);
}, onError);
}, onError);
},
onFileWriteComplete = function (file) {
// here the file should be created and available on the device
var safe = cordova.plugins.disusered.safe,
key = 'someKey',
onEncryptSuccess = function (encryptedFile) {
console.log('Encrypted file: ' + encryptedFile);
};
// file.target.localURL value is "cdvfile://localhost/persistent/userData.json"
safe.encrypt(file.target.localURL, key, onEncryptSuccess, onError);
};
document.addEventListener('deviceready', onDeviceReady, false);
In the code above onEncryptSuccess
or onError
should be called.
The function onFileWriteComplete
is called and the file exists on the device with the rights: -rw-rw----
.
So i've got the lib up and in the dom in android, but I'm consistently getting an error code 1 when running encrypt.
here's my code:
Meteor.enc.safe.encrypt = (fn)->
console.log "about to encrypt: "+fn
success = (encryptedFile) ->
console.log 'Encrypted file: ' + encryptedFile
return
error = (c)->
console.log 'Error with encryption operation, code: ' + c.toString()
return
Meteor.enc.safe.safe.encrypt fn, "someKey", success, error
I'm recording a video using the cordova-plugin-media-capture plugin then using the cordova-plugin-file plugin to resolve the fileEntry object. From that I've tried calling the above with:
-the fileEntry.nativeURL property (ex. "file:///storage/emulated/0/DCIM/Camera/VID_20150806_122744.3gp")
-the fileEntry.fullPath property (ex. "/DCIM/Camera/VID_20150806_122744.3gp")
-the fileEntry.toInternalURL() path (ex. "cdvfile://localhost/persistent/DCIM/Camera/VID_20150806_123214.3gp")
didn't really expect the last one to work but figured I'd try. All of these return an error code 1. Any idea what might be going on? I expected the nativeURL to be the right thing to pass, but no luck.
Getting Error: 404 Not Found: org.disusered.safe
:app:compileDebugJavaWithJavac
..\youtube-download\platforms\android\app\src\main\java\com\disusered\Safe.java:26: error: package com.facebook.android.crypto.keychain does not exist
import com.facebook.android.crypto.keychain.SharedPrefsBackedKeyChain;
^
F:\santanu\youtube-download\platforms\android\app\src\main\java\com\disusered\Safe.java:120: error: cannot find symbol
CRYPTO = new Crypto(new SharedPrefsBackedKeyChain(CONTEXT), new SystemNativeCryptoLibrary());
^
symbol: class SharedPrefsBackedKeyChain
location: class Safe
2 errors
FAILED
FAILURE: Build failed with an exception.
Compilation failed; see the compiler error output for details.
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
Get more help at https://help.gradle.org
BUILD FAILED in 1m 46s
(node:3416) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: cmd: Command failed with exit code 1 Error output:
F:\santanu\youtube-download\platforms\android\app\src\main\java\com\disusered\Safe.java:26: error: package com.facebook.android.crypto.keychain does not exist
import com.facebook.android.crypto.keychain.SharedPrefsBackedKeyChain;
^
F:\santanu\youtube-download\platforms\android\app\src\main\java\com\disusered\Safe.java:120: error: cannot find symbol
CRYPTO = new Crypto(new SharedPrefsBackedKeyChain(CONTEXT), new SystemNativeCryptoLibrary());
^
symbol: class SharedPrefsBackedKeyChain
location: class Safe
2 errors
I am using OS X and started with the quick start guide for ionic here.
What i have done:
console.log('$ionicView.afterEnter');
var safe = cordova.plugins.disusered.safe,
key = 'someKey';
function success(encryptedFile) {
console.log('Encrypted file: ' + encryptedFile);
}
function error(err) {
console.log('Error with cryptographic operation: ' + err);
}
console.log('Path: ' + p);
safe.decrypt(p, key, success, error);
}
})`
Result:
Whatever i do, i get Error with cryptographic operation: 1.
At first i thought i am working on the wrong path, but a test with resolveLocalFileSystemURL and FIleEntry.moveTo showed that i can rename the corresponding file. So i can access it with r/w rights.
Expected Result:
Encrypted version of the file
I have uploaded the current situation here, everything except the builded files.
Hi!
I've just started testing this plugin on iOS and it looks very promising. I was wondering if someone could share some example usage for iOS since it doesn't seem to work (at least on the emulator).
For example, I'm using it within angular and doin' something like that:
controller('Controller', [
'$scope',
'$cordovaFile',
function($scope, $cordovaFile) {
var safe = cordova.plugins.disusered.safe,
key = 'myKey';
$cordovaFile.checkFile( cordova.file.dataDirectory, 'file.enc' )
.then(function (success) {
safe.decrypt(success.nativeURL, key, function(decryptedFile) {
$scope.img = decryptedFile;
});
}, function (error) {
console.log(error);
});
}]);
What I expect is to read an encrypted image and embed it in my current view. I use the file plugin to check if the file actually exists and tried both fullPath and nativeURL but it still doesn't seem to work.
Any hint?
Another question, if you don't mind: do this plugin decrypt the file in-place or is it possible to read it on the fly leaving the original file untouched?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.