Giter Club home page Giter Club logo

cordova-plugin-scrypt's Introduction

Scrypt plugin for iOS & Android

Introduction

scrypt is a password-based key derivation function designed to make it costly to perform hardware attacks on the derived keys. While there exist scrypt implentations for the browser in javascript they are extremely slow and impractical for use in mobile apps.

This plugin is for use with Cordova and allows your application to use scrypt on iOS/Android devices using native C code. It is based on libscrypt.

Contents

Installation

Below are the methods for installing this plugin automatically using command line tools. For additional info, take a look at the Plugman Documentation and Cordova Plugin Specification.

Cordova

The plugin can be installed via the Cordova command line interface:

  • Navigate to the root folder for your phonegap project.
  • Run the command:
cordova plugin add cordova-plugin-scrypt

or if you want to be running the development version,

cordova plugin add https://github.com/Crypho/cordova-plugin-scrypt.git

Plugin API

Grab the plugin instance variable.

var scrypt;

document.addEventListener("deviceready", function(){
    scrypt = window.plugins.scrypt;
    ...
});

You can get the derived key in hexadecimal format by invoking scrypt(onSuccess, onFailure, password, salt, options)

var key;

scrypt(
    function (res) { key = res; },
    function (err) { key = null },
    'password', 'salt', {N: 16384}
)

The password or salt parameters can be a string or an array of uint8. You can provide custom scrypt parameters in the options dict. The defaults are

{
    N: 16384,
    r: 8,
    p: 1,
    dkLen: 32
}

Testing

Setup

  1. Create a cordova app.
  2. Replace config.xml with the testing.config.xml
  3. Add your platforms.
  4. Add the cordova-plugin-test-framework plugin:
cordova plugin add http://git-wip-us.apache.org/repos/asf/cordova-plugin-test-framework.git
  1. Finally add the scrypt plugin as well as the tests from its location
cordova plugin add PATH_TO_SCRYPT_PLUGIN
cordova plugin add PATH_TO_SCRYPT_PLUGIN/tests

Running the tests

Just run the app for all platforms. Remember, if you have changes to test you will need to remove the scrypt plugin and add it again for the changes to be seen by the app.

LICENSE

The MIT License

Copyright (c) 2015 Crypho AS.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

libscrypt is Copyright (c) 2013, Joshua Small under the BSD license. See src/libscrypt/LICENSE

cordova-plugin-scrypt's People

Contributors

demetris-manikas avatar ggozad avatar j-berman avatar

Watchers

 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.