Simplify code-flow of Key.encrypt

This commit is contained in:
evilaliv3 2016-04-28 15:59:55 +02:00
parent a5fdc36062
commit 0d93127186

View File

@ -370,11 +370,13 @@ Key.prototype.getEncryptionKeyPacket = function() {
* @param {String} passphrase * @param {String} passphrase
*/ */
Key.prototype.encrypt = function(passphrase) { Key.prototype.encrypt = function(passphrase) {
if (this.isPrivate()) { if (!this.isPrivate()) {
var keys = this.getAllKeyPackets(); throw new Error("Nothing to encrypt in a public key");
for (var i = 0; i < keys.length; i++) { }
keys[i].encrypt(passphrase);
} var keys = this.getAllKeyPackets();
for (var i = 0; i < keys.length; i++) {
keys[i].encrypt(passphrase);
} }
}; };