Giter VIP home page Giter VIP logo

aerogear-cordova-crypto's Introduction

AeroGear Crypto Plugin

Project Info
License: Apache License, Version 2.0
Build: Cordova Plugin
Documentation: https://aerogear.org/docs/specs/aerogear-cordova/
Issue tracker: https://issues.jboss.org/browse/AGCORDOVA
Mailing lists: aerogear-users (subscribe)
aerogear-dev (subscribe)

This plugin allows you to use the native aerogear crypto libs for your cordova apps. While staying close to the aerogear-js api.

  • Password based key derivation support (PBKDF2)
var agCrypto = new AeroGear.Crypto();
agCrypto.deriveKey('my password', null, {
    success: function (rawPassword) {
        console.log(rawPassword);
    }
});
  • Symmetric encryption support (GCM)

    • Encryption:
Promise.all([agCrypto.deriveKey('my password'), agCrypto.getRandomValue()])
    .then(function (rawPassword, IV) {
            var options = {
                IV: IV[0],
                key: rawPassword[0],
                data: "My Bonnie lies over the ocean, my Bonnie lies over the sea"
            };
            agCrypto.encrypt(options).then(function (cipherText) {
                console.log(cipherText);
            });
        },
        function (error) {
            console.log('error ' + error);
        });
        
// or with regular callbacks

agCrypto.deriveKey('my password', null, {
    success: function (rawPassword) {
        agCrypto.getRandomValue({
            success: function (generatedIV) {
                var options = {
                    IV: generatedIV,
                    key: rawPassword,
                    data: "My Bonnie lies over the ocean, my Bonnie lies over the sea"
                };
                agCrypto.encrypt(options, {
                    success: function (cipherText) {
                        console.log(cipherText);
                    }
                });
            }
        });
    }
});
  • Decryption:
var options = {
    IV: "69696ee955b62b73cd62bda875fc73d68219e0036b7a0b37",
    AAD: "feedfacedeadbeeffeedfacedeadbeefabaddad2",
    key: rawPassword,
    data: cipherText
};
AeroGear.Crypto().decrypt(options, {
    success: function (text) {
        console.log(text);
    }
});
  • Asymmetric encryption support (ECC) / iOS not supported
Promise.all([agCrypto.KeyPair(), agCrypto.KeyPair(), agCrypto.getRandomValue()])
    .then(function (keyPair, keyPairPandora, IV) {
        var options = {
            IV: IV[0],
            key: new agCrypto.KeyPair(keyPair[0].privateKey, keyPairPandora[0].publicKey),
            data: "My bonnie lies over the ocean"
        };
        agCrypto.encrypt(options).then(function (cipherText) {
            options.key = new agCrypto.KeyPair(keyPairPandora[0].privateKey, keyPair[0].publicKey);
            options.data = cipherText;
            agCrypto.decrypt(options).then(function (plainText) {
                console.log('plainText ' + plainText);
            });
        });

    });

Installing

cordova create <PATH> [ID] [NAME]
cd <PATH>
# only ios and android are supported
cordova platform add <PLATFORM>
cordova plugin install https://github.com/edewit/aerogear-crypto-cordova

# after adding the plugin for ios you'll have to run:
cd platforms/ios
pod install

Documentation

For more details about the current release, please consult our documentation.

Development

If you would like to help develop AeroGear you can join our developer's mailing list, join #aerogear on Freenode, or shout at us on Twitter @aerogears.

Also takes some time and skim the contributor guide

Questions?

Join our user mailing list for any questions or help! We really hope you enjoy app development with AeroGear!

Found a bug?

If you found a bug please create a ticket for us on Jira with some steps to reproduce it.

aerogear-cordova-crypto's People

Contributors

edewit avatar lfryc avatar matzew avatar

Watchers

 avatar  avatar

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.