From 19387bcac83ba71117fded8d71f650a84692670a Mon Sep 17 00:00:00 2001 From: devpotatoes Date: Tue, 29 Jul 2025 09:36:39 +0200 Subject: [PATCH] Adding apx.crypto --- wco/crypto/crypto.js | 61 ++++++++++++++++++++++++++++++++++++++++++++ wco/itm/crypto.json | 17 ++++++++++++ 2 files changed, 78 insertions(+) create mode 100644 wco/crypto/crypto.js create mode 100644 wco/itm/crypto.json diff --git a/wco/crypto/crypto.js b/wco/crypto/crypto.js new file mode 100644 index 0000000..7f52ffb --- /dev/null +++ b/wco/crypto/crypto.js @@ -0,0 +1,61 @@ +var apx = apx || {}; + +apx.crypto = apx.crypto || {}; + +apx.crypto.genKey = async (uuid) => { + return await openpgp.generateKey( + { + type: "ecc", + curve: "curve25519", + userIDs: [ + { + alias: uuid + } + ], + passphrase: "", + format: "armored", + } + ); +}; + +apx.crypto.encryptMessage = async (message, publicKey) => { + publicKey = await openpgp.readKey( + { + armoredKey: publicKey + } + ); + + return await openpgp.encrypt( + { + message: await openpgp.createMessage( + { + text: message + } + ), + encryptionKeys: publicKey + } + ); +}; + +apx.crypto.decryptMessage = async (encryptedMessage, privateKey) => { + privateKey = await openpgp.readPrivateKey( + { + armoredKey: privateKey + } + ); + + const message = await openpgp.readMessage( + { + armoredMessage: encryptedMessage + } + ); + + return await openpgp.decrypt( + { + message, + decryptionKeys: privateKey + } + ); +}; + +export default apx; \ No newline at end of file diff --git a/wco/itm/crypto.json b/wco/itm/crypto.json new file mode 100644 index 0000000..7df6931 --- /dev/null +++ b/wco/itm/crypto.json @@ -0,0 +1,17 @@ +{ + "wconame": "crypto", + "owner": "philc", + "price": 1, + "aliascode": [], + "commentaliascode": "if paid wco then [tribename_uniquecode,...]", + "codehash": "123", + "thumbnail": "", + "title": "Crypto lib using openpgp for apxrtri", + "description": "", + "tpl": {}, + "tpldata": {}, + "ref": { + "Checkjson": "apxtri/models/tplstrings/Checkjson", + "Notification": "apxtri/models/tplstrings/Notifications", "Middlewares": "apxtri/models/tplstrings/Middlewares" + } +} \ No newline at end of file