Be responsive when generating private key
This commit is contained in:
parent
4609cc114f
commit
7c3ba9ecaa
48
js/crypto.js
48
js/crypto.js
@ -112,29 +112,37 @@ function signMessage(text, key, callback) {
|
||||
* @returns {undefined}
|
||||
*/
|
||||
function generatePrivateKey(userid, passphrase, callback) {
|
||||
var F = kbpgp["const"].openpgp;
|
||||
var statustextEl = $("#statustext");
|
||||
statustextEl.html("<i class='fas fa-spin fa-spinner'></i> Generating cryptographic key...");
|
||||
setTimeout(function () {
|
||||
var F = kbpgp["const"].openpgp;
|
||||
|
||||
var opts = {
|
||||
userid: userid,
|
||||
primary: {
|
||||
nbits: 2048,
|
||||
flags: F.certify_keys | F.sign_data | F.auth | F.encrypt_comm | F.encrypt_storage,
|
||||
expire_in: 0 // never expire
|
||||
},
|
||||
subkeys: []
|
||||
};
|
||||
var opts = {
|
||||
userid: userid,
|
||||
primary: {
|
||||
nbits: 2048,
|
||||
flags: F.certify_keys | F.sign_data | F.auth | F.encrypt_comm | F.encrypt_storage,
|
||||
expire_in: 0 // never expire
|
||||
},
|
||||
subkeys: []
|
||||
};
|
||||
|
||||
kbpgp.KeyManager.generate(opts, function (err, alice) {
|
||||
if (!err) {
|
||||
alice.sign({}, function (err) {
|
||||
alice.export_pgp_private({
|
||||
passphrase: passphrase
|
||||
}, function (err, pgp_private) {
|
||||
callback(alice);
|
||||
kbpgp.KeyManager.generate(opts, function (err, alice) {
|
||||
if (!err) {
|
||||
alice.sign({}, function (err) {
|
||||
alice.export_pgp_private({
|
||||
passphrase: passphrase
|
||||
}, function (err, pgp_private) {
|
||||
statustextEl.html("<i class='fas fa-check'></i> Key generated!");
|
||||
setTimeout(function () {
|
||||
statustextEl.html("");
|
||||
}, 5000);
|
||||
callback(alice);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}, 100);
|
||||
}
|
||||
|
||||
function exportPublicKey() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user