1 line
2.4 KiB
JavaScript
1 line
2.4 KiB
JavaScript
/*! OpenPGPjs.org this is LGPL licensed code, see LICENSE/our website for more information.- v0.0.1 - 2013-12-26 */require=function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);throw new Error("Cannot find module '"+g+"'")}var j=c[g]={exports:{}};b[g][0].call(j.exports,function(a){var c=b[g][1][a];return e(c?c:a)},j,j.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g<d.length;g++)e(d[g]);return e}({fjvtDg:[function(a,b){b.exports=a("./keyring.js"),b.exports.localstore=a("./localstore.js")},{"./keyring.js":3,"./localstore.js":4}],keyring:[function(a,b){b.exports=a("fjvtDg")},{}],3:[function(a,b){var c=a("openpgp");b.exports=function(b){function d(a,b){a=a.toLowerCase();for(var c,d=b.getUserIds();c<d.length;c++)if(keyEmail=d[c].split("<")[1].split(">")[0].trim().toLowerCase(),keyEmail==a)return!0;return!1}function e(a,b){for(var d=b.getKeyIds(),e=0;e<d.length;e++)if(c.util.hexstrdump(d[e].write())==a)return!0;return!1}function f(a,b,d,e){for(var f=[],g=0;g<a.length;g++){var h=a[g];switch(e){case c.enums.packet.public_key:h.isPublic()&&b(d,h)&&f.push(h);break;case c.enums.packet.private_key:h.isPrivate()&&b(d,h)&&f.push(h)}}return f}b||(b=new(a("./localstore.js"))),this.storeHandler=b,this.keys=this.storeHandler.load(),this.store=function(){this.storeHandler.store(this.keys)},this.clear=function(){this.keys=[]},this.getPublicKeyForAddress=function(a){return f(this.keys,d,a,c.enums.packet.public_key)},this.getPrivateKeyForAddress=function(a){return f(this.keys,d,a,c.enums.packet.secret_key)},this.getKeysForKeyId=function(a){return f(this.keys,e,a,c.enums.packet.public_key)},this.importKey=function(a){return this.keys=this.keys.concat(c.key.readArmored(a).keys),!0},this.exportKey=function(a){return this.keys[a].armor()},this.removeKey=function(a){var b=this.keys.splice(a,1);return b},this.exportPublicKey=function(a){return this.keys[a].toPublic().armor()}}},{"./localstore.js":4}],4:[function(a,b){var c=a("openpgp");b.exports=function(){this.load=function(){var a=JSON.parse(window.localStorage.getItem("armoredKeys")),b=[];if(null!==a&&0!==a.length)for(var d,e=0;e<a.length;e++)d=c.key.readArmored(a[e]),b.push(d);return b},this.store=function(a){for(var b=[],c=0;c<a.length;c++)b.push(a[c].armor());window.localStorage.setItem("armoredKeys",JSON.stringify(b))}}},{}]},{},[]); |