The EncryptedStorage class is used as a secure local store.
Note: There is a security flaw on some versions of Android with the Pseudo Random Number Generation. The first time the native code of this plugin runs it applies the fix for this issue. However, the fix needs to be applied before any use of Java Cryptography Architecture primitives. Therefore, it is a good idea to run this plugin (call a function that has a native component: length, key, getItem, setItem, removeItem, clear) before using any other security-related plugin, to protect yourself against the possibility that the other plugin does not apply this fix. No other Kapsel plugins are affected, so you need not do this on their behalf. For more details about the security flaw, see http://android-developers.blogspot.com/2013/08/some-securerandom-thoughts.html
Adding and Removing the EncryptedStorage Plugin
The EncryptedStorage plugin is added and removed using the Cordova CLI.
To add the EncryptedStorage plugin to your project, use the following command:
cordova plugin add <path to directory containing Kapsel plugins>\encryptedstorage
To remove the EncryptedStorage plugin from your project, use the following command:
cordova plugin rm com.sap.mp.cordova.plugins.encryptedstorage
Name | Description |
COMPLEX_STRING_MAXIMUM_LENGTH | This constant is the length of the largest string that is guaranteed to be successfully stored on Android. |
ERROR_BAD_PASSWORD | This error code indicates that the operation failed due to an incorrect password. |
ERROR_GREATER_THAN_MAXIMUM_SIZE | This error indicates that the string was too large to store. |
ERROR_INVALID_PARAMETER | This error code indicates an invalid parameter was provided. (eg: a string given where a number was required). |
ERROR_UNKNOWN | This error code indicates an unknown error occurred. |
SIMPLE_STRING_MAXIMUM_LENGTH | This constant is the length of the largest string that can successfully be stored on Android. |
Name | Description |
clear( successCallback, errorCallback ) | This function removes all items from the store. |
getItem( key, successCallback, errorCallback ) | This function gets the value corresponding to the given key. |
key( index, successCallback, errorCallback ) | This function gets the key corresponding to the given index. |
length( successCallback, errorCallback ) | This function gets the length of the store. |
removeItem( key, successCallback, errorCallback ) | This function removes the item corresponding to the given key. |
setItem( key, value, successCallback, errorCallback ) | This function sets an item with the given key and value. |
Name | Description |
errorCallback( errorCode ) | Callback function that is invoked in case of an error. |
getItemSuccessCallback( value ) | |
keySuccessCallback( key ) | |
lengthSuccessCallback( length ) | |
successCallback | Callback function that is invoked on a successful call to a function that does not need to return anything. |