Adding apx.crypto
This commit is contained in:
61
wco/crypto/crypto.js
Normal file
61
wco/crypto/crypto.js
Normal file
@@ -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;
|
17
wco/itm/crypto.json
Normal file
17
wco/itm/crypto.json
Normal file
@@ -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"
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user