mirror of
https://github.com/AleziaKurdis/Overte-community-apps.git
synced 2025-08-08 05:07:51 +02:00
22 lines
691 B
JavaScript
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);
|
|
}
|
|
})();
|