Skip to content

rd-uk/cordova-plugin-rduksecurity

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RDUK - Security Cordova Plugin

Supported OS

  • Android (api level 18+)

Installation

cordova plugin add https://github.com/rd-uk/cordova-plugin-rduksecurity.git

API Reference


security

security.certificate

security.certificate.generate(name, successCallback, errorCallback)

Generates a certificate stored in KeyStore for android device. The public key is passed to the success callback as a Base64-encoded String.

Note: if alias already exists, the existing public key is passed to the success callback.

var onSuccess = function(data) {
    /* ... */
};

var onError = function(message) {
    /* ... */
};

security.certificate.generate('alias...', onSuccess, onError);

security.digest

security.digest.md5digest(message, successCallback, errorCallback)

Generates a MD5 hash of message, passed to the success callback as Base64-encoded String.

var onSuccess = function(data) {
    console.log(data); // will output: uVkG1pQIp3QD8df1FdvMBw==
};

var onError = function(message) {
    /* Oops, something goes wrong... */
};

security.digest.md5digest('rduk', onSuccess, onError);

security.digest.sha1digest(message, successCallback, errorCallback)

Generates a SHA-1 hash of message, passed to the success callback as Base64-encoded String.

var onSuccess = function(data) {
    console.log(data); // will output: xhZASyUDRjjsAZVzRKp16OpERK0=
};

var onError = function(message) {
    /* Oops, something goes wrong... */
};

security.digest.sha1digest('rduk', onSuccess, onError);

security.digest.sha256digest(message, successCallback, errorCallback)

Generates a SHA-256 hash of message, passed to the success callback as Base64-encoded String.

var onSuccess = function(data) {
    console.log(data); // will output: qoNyp5fmrKx26h69RVjP/H4TtPQtxGXTWlDC/MRiCjo=
};

var onError = function(message) {
    /* Oops, something goes wrong... */
};

security.digest.sha256digest('rduk', onSuccess, onError);

security.message

security.message.sign(messageToSign, keyAlias, successCallback, errorCallback)

var onSuccess = function(data) {
    /* ... */
};

var onError = function(message) {
    /* ... */
};

security.digest.sha256digest(
    'my message to sign',
    function(digest) {
        security.message.sign(
            digest, 'certificate alias...', onSuccess, onError);
    },
    , onError);

security.message.verify(messageToVerify, signature, keyAlias, successCallback, errorCallback)

var onSuccess = function(data) {
    /* ... */
};

var onError = function(message) {
    /* ... */
};

security.digest.sha256digest(
    'my message to verify',
    function(digest) {
        security.message.verify(
            digest, 'signature...', 'certificate alias...', onSuccess, onError);
    },
    , onError);

About

messages signing and verifying on cordova app

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published