Newts Parading Majestically

    gpg-with-err-handling

    1.0.7 • Public • Published

    A wrapper on node-gpg with error handling for bad passphrase and wrong secret key

    npm downloads

    This module is a wrapper around Node-GPG for use within Node. It takes care of spawning gpg, passing it the correct arguments, and piping input to stdin. It can also pipe input in from files and output out to files. It also helps you identified if the passphrase or secret key is wrong.

    Use Node-GPG if you are considering calling gpg directly from your application.

    Requirements

    In order to use gpg-with-err-handling, you'll need to have the gpg binary in your $PATH.

    Installation

    npm install gpg-with-err-handling
    

    Usage

    Gpg-With-Err-Handling supports both direct calls to GPG with string arguments, and streaming calls for piping input and output from/to files.

        gpg.importKey(privateKey, [], (err, success) => {
          if(!err){
              const args = [
                '--pinentry-mode',
                'loopback',
                '--passphrase',
                passphrase,
              ];
    
            gpg.callStreaming(<encrypted file stream>, <output file name>, args, async (error, data) => {
                if(success) {
                  // post success logic
                }
            });
          }
        });
    

    See the source for more details.

    If a function you need is not implemented, you can call gpg directly with arguments of your choice by calling gpg.call(stdinStr, argsArray, cb), or gpg.callStreaming(inputFileName, outputFileName, argsArray, cb).

    Notes

    Existing implementations of PGP in Javascript are blocking and unfeasibly slow for server use. In casual testing, encrypting a simple 400-character email to an El-Gamal key took upwards of 11 seconds using openpgpjs and 14 seconds with kbpgp, but takes less than 0.1 seconds with gpg directly.

    Contributors

    The following are the major contributors of gpg-with-err-handling (in no specific order).

    Install

    npm i gpg-with-err-handling

    DownloadsWeekly Downloads

    90

    Version

    1.0.7

    License

    MIT

    Unpacked Size

    31.9 kB

    Total Files

    14

    Last publish

    Collaborators

    • vivmehra