End-to-End Encryption
End-to-end encryption ensures that only the communicating parties can access and read the message content. Any third party, including Alien's servers, cannot decrypt this information.
Asymmetric Encryption (RSA): Uses RSA public/private key pairs for message encryption and decryption. The sender encrypts the message with the receiver's public key, and the receiver decrypts it with their private key.
Symmetric Encryption (AES): To improve efficiency, message content is encrypted using AES symmetric encryption, with the key transmitted using RSA encryption.
// Example: End-to-End Encrypted Messages
import { encrypt, decrypt, generateKeyPair } from 'crypto';
const { publicKey, privateKey } = generateKeyPair();
// Encrypting Messages
function encryptMessage(message, recipientPublicKey) {
const encryptedMessage = encrypt(recipientPublicKey, Buffer.from(message));
return encryptedMessage.toString('base64');
}
// Decrypting Messages
function decryptMessage(encryptedMessage, recipientPrivateKey) {
const decryptedMessage = decrypt(recipientPrivateKey, Buffer.from(encryptedMessage, 'base64'));
return decryptedMessage.toString();
}