{"library":"node-gpg","title":"Node.js GnuPG Wrapper","description":"node-gpg is a Node.js wrapper that provides an interface to the GnuPG (GNU Privacy Guard) command-line utility, allowing JavaScript applications to perform cryptographic operations like encryption, decryption, signing, and verification. It was last published as version 0.2.0 in February 2020 and explicitly stated as 'work in progress' at that time. The project appears to be abandoned, with no activity since early 2020. It differentiates itself by offering a promise-based API, making it suitable for async/await patterns, unlike some older GPG wrappers. However, due to its inactivity, it may not be compatible with newer Node.js versions or GnuPG releases, and it lacks active maintenance or security updates.","language":"javascript","status":"abandoned","last_verified":"Sun Apr 19","install":{"commands":["npm install node-gpg"],"cli":null},"imports":["const gpg = require('node-gpg');","const { encrypt } = require('node-gpg');","const { decrypt } = require('node-gpg');"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"const gpg = require('node-gpg');\nconst path = require('path');\nconst fs = require('fs');\n\n// Ensure a 'test' key exists in your GPG keyring, e.g., by creating one:\n// gpg --full-generate-key\n// Use 'test' as the User ID\n\nasync function encryptAndDecryptMessage() {\n    try {\n        const plaintext = 'This is a secret message!';\n        const recipientKeyId = 'test'; // Replace with a key ID from your keyring\n        const outputEncryptedPath = path.resolve(__dirname, './encrypted_message.gpg');\n        const outputDecryptedPath = path.resolve(__dirname, './decrypted_message.txt');\n\n        console.log(`Encrypting: \"${plaintext}\" for key ID: \"${recipientKeyId}\"`);\n        const encryptedData = await gpg.encrypt(recipientKeyId, plaintext);\n        fs.writeFileSync(outputEncryptedPath, encryptedData);\n        console.log('Encrypted data written to:', outputEncryptedPath);\n\n        console.log('Decrypting the message...');\n        const decryptedData = await gpg.decrypt(encryptedData);\n        fs.writeFileSync(outputDecryptedPath, decryptedData);\n        console.log('Decrypted data written to:', outputDecryptedPath);\n        console.log('Decrypted content:', decryptedData);\n\n        console.log('\\nEncryption and decryption successful!');\n    } catch (error) {\n        console.error('An error occurred:', error.message);\n        if (error.stderr) console.error('GPG stderr:', error.stderr);\n        console.error('Ensure GnuPG is installed and configured, and the recipient key exists.');\n    }\n}\n\nencryptAndDecryptMessage();","lang":"javascript","description":"Demonstrates how to use `node-gpg` to encrypt a plaintext string for a specified recipient key and then decrypt it. This requires GnuPG to be installed and a key to be present in the keyring.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}