kbpgp
kbpgp copied to clipboard
Is there a way to import a PGP key that isn't ASCII armored?
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?
This should do it:
@import_from_pgp_message : ({msg, asp, opts}, cb) ->
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);
}
});
});
The same problem. Does anyone found the solution ?
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)
});
});