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}
|
* @returns {undefined}
|
||||||
*/
|
*/
|
||||||
function generatePrivateKey(userid, passphrase, callback) {
|
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 = {
|
var opts = {
|
||||||
userid: userid,
|
userid: userid,
|
||||||
primary: {
|
primary: {
|
||||||
nbits: 2048,
|
nbits: 2048,
|
||||||
flags: F.certify_keys | F.sign_data | F.auth | F.encrypt_comm | F.encrypt_storage,
|
flags: F.certify_keys | F.sign_data | F.auth | F.encrypt_comm | F.encrypt_storage,
|
||||||
expire_in: 0 // never expire
|
expire_in: 0 // never expire
|
||||||
},
|
},
|
||||||
subkeys: []
|
subkeys: []
|
||||||
};
|
};
|
||||||
|
|
||||||
kbpgp.KeyManager.generate(opts, function (err, alice) {
|
kbpgp.KeyManager.generate(opts, function (err, alice) {
|
||||||
if (!err) {
|
if (!err) {
|
||||||
alice.sign({}, function (err) {
|
alice.sign({}, function (err) {
|
||||||
alice.export_pgp_private({
|
alice.export_pgp_private({
|
||||||
passphrase: passphrase
|
passphrase: passphrase
|
||||||
}, function (err, pgp_private) {
|
}, function (err, pgp_private) {
|
||||||
callback(alice);
|
statustextEl.html("<i class='fas fa-check'></i> Key generated!");
|
||||||
|
setTimeout(function () {
|
||||||
|
statustextEl.html("");
|
||||||
|
}, 5000);
|
||||||
|
callback(alice);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
}
|
||||||
}
|
});
|
||||||
});
|
}, 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
function exportPublicKey() {
|
function exportPublicKey() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user