kbpgp icon indicating copy to clipboard operation
kbpgp copied to clipboard

Is there a way to import a PGP key that isn't ASCII armored?

Open JoshDobbin opened this issue 9 years ago • 4 comments

I've been able to directly add a key (public or private) to a key manager as long as the input data is ASCII armored. Unfortunately I haven't been able to add a key that is not ASCII armored.

Have any pro tips?

JoshDobbin avatar Feb 12 '16 21:02 JoshDobbin

This should do it:

@import_from_pgp_message : ({msg, asp, opts}, cb) ->

maxtaco avatar Feb 13 '16 01:02 maxtaco

Ok. I tried the code below and was told a buffer is needed but I am sending a buffer.

Here's an example:

var kbpgp = require('kbpgp'),
    fs = require('fs');

fs.readFile('keyFile.gpg', (err, data) => {
    kbpgp.KeyManager.import_from_pgp_message(
        { msg: data },
        function(err, key) {
            if(err) {
                console.log(err);
            }
        }); 
});

JoshDobbin avatar Feb 16 '16 18:02 JoshDobbin

The same problem. Does anyone found the solution ?

linuxenko avatar Oct 30 '16 07:10 linuxenko

Not ideal, but I got this to work:

var kbpgp = require('kbpgp'),
    fs = require('fs');

fs.readFile('keyFile.gpg', {"encoding" : null}, (err, data) => {
    msg = {
      body : data,
      raw : function() { return null }
    }
    kbpgp.KeyManager.import_from_pgp_message(
        { msg : msg },
        function(err, key) {
            if(err) {
                console.log(err);
            }
            console.log(key)
        });
});

maxtaco avatar Oct 31 '16 13:10 maxtaco