npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

gpgme

v0.0.1

Published

Bindings for Gnu Privacy Guard

Readme

node-gpg

GNU Privacy Guard (GPG) bindings for node.js supporting public key cryptography, encryption, decryption, signing and verification. This is based off of the GnuPG Made Easy (GPGME) GPG C library, see its very good documentation for more information.

License

GNU GENERAL PUBLIC LICENSE v3, see the COPYING file in this directory.

Installation

npm install gpgme

Usage

  • Also see the test.js file in this directory for example usage.
  • Currently uses JavaScript strings for all data input and output.
  • Uses ASCII Armor for all encrypted output.

Require gpg and initialize a new context.

var gpg = require('gpgme');

Verify

To verify a message with a signature. First generate the signature which can be done with the following in the shell (the -a indicates ASCII armor output).

sig=$(echo foo|gpg --detach-sign -a|sed ':a;N;$!ba;s/\n/\\\\n/g')
echo "{\"content\":\"foo\\\\n\", \"signature\":\"$sig\"}" |tee msg.json

Then save your signature to a JavaScript string, and run the following (or run node test.js).

var msg = JSON.parse(fs.readFileSync('./msg.json', 'utf8'));

if(gpg.verify(msg.signature,msg.content))
  console.log("verification success");
else
  console.log("verification failure");

Decrypt

To decrypt an encrypted message. First generated encrypted content by running the following in a shell.

echo "secret contents"|gpg -e -r "Your GPG Name" -a|tee cipher.txt

Then run the following (or run node test.js).

var cipher = fs.readFileSync('cipher.txt', 'utf8');
var decrypted = gpg.decrypt(cipher);
console.log('decrypted content is "'+decrypted+'"');

To decrypt and verify a message. First generated encrypted content by running the following in a shell.

echo "secret signed contents"|gpg -s -e -r "Your GPG Name" -a \
  |tee signed-cipher.txt

Then run the following (or run node test.js).

var signed_cipher = fs.readFileSync('signed-cipher.txt', 'utf8');
var decrypted_and_verified = gpg.decryptAndVerify(signed_cipher);
console.log('decrypted and verified content is "'+decrypted_and_verified+'"');

Sign

To sign a message. First write a JSON hash holding the data to encrypt and the name of the signatory (this name will be used by GPG to lookup the key).

echo '{"signatory":"Your Name", "content":"foo\n"}' > sign.json

Then run the following (or run node test.js).

var sign = JSON.parse(fs.readFileSync('./sign.json', 'utf8'));
var signature = gpg.sign(sign.signatory, sign.content);
console.log('content "'+sign.content+
            '" signed by "'+sign.signatory+
            '" yields signature "'+signature+'"');

Encrypt

To encrypt a message. First write a JSON hash holding a list of the recipients and the message to encrypt.

echo '{"recipients":["Your Name"], "content":"foo\n"}' > encrypt.json

Then run the following (or run node test.js).

TODO

  • add a context class to allow multiple simultaneous operations
  • add a key class to allow key management to take place on the JS side of things
  • add support for asynchronous operations w/callbacks (gpgme should make this straightforward)