-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How can I generate key pair using this? #35
Comments
Looking at the // ... Other stuff
/**
* Raw call to gpg.
*
* @param {String} stdin String to send to stdin.
* @param {Array} [args] Array of arguments.
* @param {Function} [fn] Callback.
* @api public
*/
call: function(stdin, args, fn) {
spawnGPG(stdin, args, fn);
}, ... checking with GitHub's GPG docs states that either #!/usr/bin/env bash
## ... other stuff
Func_gen_gnupg_keys(){
_pass_phrase=( "$@" )
if [ "${#Var_gnupg_comment}" != "0" ]; then
gpg --batch --gen-key <<EOF
Key-Type: ${Var_gnupg_key_type}
Key-Length: ${Var_gnupg_key_length}
Subkey-Type: ${Var_gnupg_sub_key_type}
Subkey-Length: ${Var_gnupg_sub_key_length}
Name-Real: ${Var_gnupg_name}
Name-Comment: ${Var_gnupg_comment}
name-Email: ${Var_gnupg_email}
Expire-Date: ${Var_gnupg_expire_date}
Passphrase: ${_pass_phrase[*]}
## Uncomment the next line to not generate keys
#%dry-run
%commit
%echo finished
EOF
else
gpg --batch --gen-key <<EOF
Key-Type: ${Var_gnupg_key_type}
Key-Length: ${Var_gnupg_key_length}
Subkey-Type: ${Var_gnupg_sub_key_type}
Subkey-Length: ${Var_gnupg_sub_key_length}
Name-Real: ${Var_gnupg_name}
name-Email: ${Var_gnupg_email}
Expire-Date: ${Var_gnupg_expire_date}
Passphrase: ${_pass_phrase[*]}
%commit
%echo finished
EOF
fi
unset _pass_phrase
}
## ... more _pruning_ of non-essential code for this answer
Doing a search for // ... Other tests trimmed
it('should decrypt files', function(done){
gpg.call('', [ '--skip-verify', '--passphrase-fd', '0', '--decrypt', './test/hello.gpg' ], function(err, decrypted){
assert.ifError(err);
assert.ok(decrypted.length);
assert.equal(decrypted.toString('utf8'), 'Hello World\n');
done();
});
});
// ... and a bit more pruning to keep things relatively concise Putting some of this together one might be able to... function keyGen({key_type, length, sub_type, name, email, pass, expires}) {
let gpg_configs = '--batch --gen-key';
// ... Do stuff that checks and defaults things like `type`
// if (key_type) {
// gpg_configs += `\nKey-Type: ${key_type}`
// } else {
// gpg_configs += `\nKey-Type: DSA`
// }
// ... Then _feed_ the `call` method
GPG.call(gpg_configs, [], (err, results) => {
if (err) throw err;
// ... do stuff with results?
console.log(results);
});
} ... though this last bit is untested an incomplete, hopefully as a whole this has prepared ya to code something better. |
I'm trying to find documentation to create key pair, but there's no information regarding that.
I would like to generate key pair and store that in some database and use them later to encrypt, decrypt files.
Please guide me.
The text was updated successfully, but these errors were encountered: