Simplify code-flow of Key.encrypt
This commit is contained in:
parent
a5fdc36062
commit
0d93127186
12
src/key.js
12
src/key.js
|
@ -370,11 +370,13 @@ Key.prototype.getEncryptionKeyPacket = function() {
|
|||
* @param {String} passphrase
|
||||
*/
|
||||
Key.prototype.encrypt = function(passphrase) {
|
||||
if (this.isPrivate()) {
|
||||
var keys = this.getAllKeyPackets();
|
||||
for (var i = 0; i < keys.length; i++) {
|
||||
keys[i].encrypt(passphrase);
|
||||
}
|
||||
if (!this.isPrivate()) {
|
||||
throw new Error("Nothing to encrypt in a public key");
|
||||
}
|
||||
|
||||
var keys = this.getAllKeyPackets();
|
||||
for (var i = 0; i < keys.length; i++) {
|
||||
keys[i].encrypt(passphrase);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user