Giter VIP home page Giter VIP logo

openpgpjs's Introduction

Build Status Bountysource

OpenPGP.js

OpenPGP.js is a Javascript implementation of the OpenPGP protocol. This is defined in RFC 4880.

Node support

For server side use, install via npm:

npm install --save openpgp

Browser support

For use in browser, install via bower:

bower install --save openpgp

Or Fetch a minified build under dist.

The library can be loaded as a CommonJS module, an AMD module or accessed globally via window.openpgp.

Dependencies

OpenPGP.js only supports browsers that implement window.crypto.getRandomValues. Also, if the browsers support native WebCrypto via the window.crypto.subtle api, this will be used. Though this can be deactivated by setting config.useWebCrypto = false. In this case the library will fall back to Web Worker operations if the initWorker(workerPath) is set.

OpenPGP.js uses ES6 promises which are available in most modern browsers. If you need to support browsers that do not support Promises, fear not! There is a polyfill, which is included in the build step. So no action required on the developer's part for promises!

Examples

Generate new keypair

var openpgp = require('openpgp');

var options = {
    numBits: 2048,
    userId: 'Jon Smith <[email protected]>',
    passphrase: 'super long and hard to guess secret'
};

openpgp.generateKeyPair(options).then(function(keypair) {
    // success
    var privkey = keypair.privateKeyArmored;
    var pubkey = keypair.publicKeyArmored;
}).catch(function(error) {
    // failure
});

Encryption

var openpgp = require('openpgp');

var key = '-----BEGIN PGP PUBLIC KEY BLOCK ... END PGP PUBLIC KEY BLOCK-----';
var publicKey = openpgp.key.readArmored(key);

openpgp.encryptMessage(publicKey.keys, 'Hello, World!').then(function(pgpMessage) {
    // success
}).catch(function(error) {
    // failure
});

Decryption

var openpgp = require('openpgp');

var key = '-----BEGIN PGP PRIVATE KEY BLOCK ... END PGP PRIVATE KEY BLOCK-----';
var privateKey = openpgp.key.readArmored(key).keys[0];
privateKey.decrypt('passphrase');

var pgpMessage = '-----BEGIN PGP MESSAGE ... END PGP MESSAGE-----';
pgpMessage = openpgp.message.readArmored(pgpMessage);

openpgp.decryptMessage(privateKey, pgpMessage).then(function(plaintext) {
    // success
}).catch(function(error) {
    // failure
});

Documentation

A jsdoc build of our code comments is available at doc/index.html. Public calls should generally be made through the OpenPGP object doc/openpgp.html.

Security Audit

To date the OpenPGP.js code base has undergone two complete security audits from Cure53. The first audit's report has been published here.

Security recommendations

It should be noted that js crypto apps deployed via regular web hosting (a.k.a. host-based security) provide users with less security than installable apps with auditable static versions. Installable apps can be deployed as a Firefox or Chrome packaged app. These apps are basically signed zip files and their runtimes typically enforce a strict Content Security Policy (CSP) to protect users against XSS. This blogpost explains the trust model of the web quite well.

It is also recommended to set a strong passphrase that protects the user's private key on disk.

Development

To create your own build of the library, just run the following command after cloning the git repo. This will download all dependencies, run the tests and create a minifed bundle under dist/openpgp.min.js to use in your project:

npm install && npm test

Mailing List

You can sign up for our mailing list and ask for help there. We've recently worked on getting our archive up and running.

How do I get involved?

You want to help, great! Go ahead and fork our repo, make your changes and send us a pull request.

License

GNU Lesser General Public License (3.0 or any later version). Please take a look at the LICENSE file for more information.

Resources

Below is a collection of resources, many of these were projects that were in someway a precursor to the current OpenPGP.js project. If you'd like to add your link here, please do so in a pull request or email to the list.

openpgpjs's People

Contributors

seancolyer avatar robert-nelson avatar dreamingofelectricsheep avatar alexanderwillner avatar tanx avatar toberndo avatar b11z avatar misjoinder avatar atrevarrow avatar carbureted avatar laktak avatar arzeth avatar omeid avatar inovari avatar freewil avatar cryptoreddit avatar yoshuawuyts avatar ratik avatar koto avatar evilaliv3 avatar adhintz avatar irdan avatar dcposch avatar cdwiegand avatar arlolra avatar alessioalex 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.