diff --git a/src/openpgp.js b/src/openpgp.js index b6a4b7d9..4538f982 100644 --- a/src/openpgp.js +++ b/src/openpgp.js @@ -59,6 +59,10 @@ function initWorker(path) { * @static */ function encryptMessage(keys, text, callback) { + if (typeof keys === 'string') { + keys = [keys]; + } + if (useWorker(callback)) { asyncProxy.encryptMessage(keys, text, callback); return; @@ -165,6 +169,10 @@ function decryptAndVerifyMessage(privateKey, publicKeys, msg, callback) { * @static */ function signClearMessage(privateKeys, text, callback) { + if (typeof privateKeys === 'string') { + privateKeys = [privateKeys]; + } + if (useWorker(callback)) { asyncProxy.signClearMessage(privateKeys, text, callback); return; diff --git a/src/worker/async_proxy.js b/src/worker/async_proxy.js index 1d9af298..cfa615b8 100644 --- a/src/worker/async_proxy.js +++ b/src/worker/async_proxy.js @@ -101,6 +101,9 @@ AsyncProxy.prototype.terminate = function() { * @param {Function} callback receives encrypted ASCII armored message */ AsyncProxy.prototype.encryptMessage = function(keys, text, callback) { + if (typeof keys === 'string') { + keys = [keys]; + } keys = keys.map(function(key) { return key.toPacketlist(); }); @@ -193,6 +196,9 @@ AsyncProxy.prototype.decryptAndVerifyMessage = function(privateKey, publicKeys, * @param {Function} callback receives ASCII armored message */ AsyncProxy.prototype.signClearMessage = function(privateKeys, text, callback) { + if (typeof privateKeys === 'string') { + privateKeys = [privateKeys]; + } privateKeys = privateKeys.map(function(key) { return key.toPacketlist(); }); diff --git a/src/worker/worker.js b/src/worker/worker.js index 844072da..b1636e83 100644 --- a/src/worker/worker.js +++ b/src/worker/worker.js @@ -38,6 +38,9 @@ onmessage = function (event) { break; case 'encrypt-message': try { + if (typeof msg.keys === 'string') { + msg.keys = [msg.keys]; + } msg.keys = msg.keys.map(packetlistCloneToKey); data = window.openpgp.encryptMessage(msg.keys, msg.text); } catch (e) {