How to use the openpgp.decryptMessage function in openpgp

To help you get started, we’ve selected a few openpgp examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mbilker / cypher / old / decryption / worker-decrypt.js View on Github external
function decryptRoutine() {
  var startTime = process.hrtime();
  openpgp.decryptMessage(secretKey, encryptedMessage).then(function(text) {
    var elapsed = process.hrtime(startTime);
    secretKey = encryptedMessage = null

    process.send({ method: MESSAGE_DECRYPT_TIME, timeElapsed: elapsed });
    process.send({ method: DECRYPTED_TEXT, text: text });

    setImmediate(function() {
      process.exit(0);
    });
  }, d.bind(function(err) {
    // Throw error to trigger crash
    throw err;
  }));
}
github mapmeld / profanity-pgp / decrypt.js View on Github external
for(var l = 4; l < deprofaned.length - 1; l++) {
    var original_line = deprofaned[l].split(' ');
    var new_line = "";
    for(var sym = 0; sym < original_line.length; sym++) {
      var symbol_index = profanity.indexOf(original_line[sym]);
      new_line += originalSymbols[symbol_index];
    }
    deprofaned[l] = new_line;
  }
  deprofaned = deprofaned.join('\n');

  var message = openpgp.message.readArmored(deprofaned);
  var keyids = message.getEncryptionKeyIds();
  privKey.decryptKeyPacket(keyids, ur_private_key_pass);

  openpgp.decryptMessage(privKey, message).then(function(pgpMessage) {
    console.log(pgpMessage);
  }).catch(function(err) {
    throw err;
  });
}
github mbilker / cypher / lib / decryption / in-process-decrypter.es6 View on Github external
    }).spread((text, pgpkey) => openpgp.decryptMessage(pgpkey, openpgp.message.readArmored(text)))
  }
github reelyactive / json-silo / lib / encryptionmanager.js View on Github external
if (!privateKey.decrypt(password)) {
        var error = new Error('Password is malformed');
        error.name = 'Illegal Argument';
        return callback(error, null);
      }

      pgpMessage = openpgp.message.readArmored(pgpMessage);

      if (!pgpMessage) {
        var error = new Error('Could not read the message');
        error.name = 'InternalError';
        return callback(error, null);
      }

      openpgp.decryptMessage(privateKey, pgpMessage).then(function(plaintext) {

        var jsonData = JSON.parse(plaintext);

        return callback(null, jsonData);

      }).catch(function(err) {

          if (err.action) {
            callback(err, null);
          }
      });
    },
    ],
github mbilker / cypher / lib / decryption / in-process-decrypter.es6 View on Github external
}).then((km) =>
      openpgp.decryptMessage(km, openpgp.message.readArmored(text))
    );