Overte-community-apps-Alezi.../applications/armored-chat/encrpytion.js
Armored Dragon 551117950e
Sync
Signed-off-by: Armored Dragon <publicmail@armoreddragon.com>
2024-02-21 08:54:13 -06:00

22 lines
691 B
JavaScript

(function () {
// TODO: Sign messages
// TODO: Verify signatures
let rsa = forge.pki.rsa;
let keypair;
function newKeyPair() {
// 2048 bits. Not the most super-duper secure length of 4096.
// This value must remain low to ensure lower-power machines can use.
// We will generate new keys automatically every so often and will also allow user to refresh keys.
keypair = rsa.generateKeyPair({ bits: 2048, workers: -1 });
}
function encrypt(message) {
if (!keypair) return null;
return keypair.publicKey.encrypt("Test message");
}
function decrypt(message) {
if (!keypair) return null;
return keypair.privateKey.decrypt(encrypted);
}
})();