【发布时间】:2015-07-27 02:21:19
【问题描述】:
我在我的应用程序中使用openPgpJs 库,使用 Apache Cordova 创建。
以下是部分代码:
var publicKey = openpgp.key.readArmored(_publicKey);
openpgp.encryptMessage(publicKey.keys, text).then(function (pgpMessage) {
// success
callback(pgpMessage);
}).catch(function (error) {
// failure
console.error(error);
});
它工作正常,但不适用于 WP8。如果失败,因为openpgp var 未定义。在那个库源中,一开始就有这样的代码:
!function (e) {
"object" == typeof exports ? module.exports = e() : "function" == typeof define && define.amd ? define(e) : "undefined" != typeof window ? window.openpgp = e() : "undefined" != typeof global ? global.openpgp = e() : "undefined" != typeof self && (self.openpgp = e())
}
所以应该定义openpgp。我怎样才能让它发挥作用?
更新
我添加了var openpgp = window.openpgp;,错误消失了。现在它无法加密消息 - 并且很难调试,因为库代码被缩小了
【问题讨论】:
标签: javascript cordova windows-phone-8 openpgp openpgp.js