UNPKG

e2ee-chat

Version:

A simple realtime chat SDK for web and mobile apps using socket.io with support for end-to-end encryption and multi-tenant backend integration.

46 lines (38 loc) โ€ข 1.52 kB
const { encryptMessage, decryptMessage } = require("./src/encryption"); // Test encryption/decryption with the same secret key as Flutter const SECRET_KEY = "shared-secret-123"; const TEST_MESSAGE = "Hello from test message!"; console.log("๐Ÿงช Testing Encryption/Decryption"); console.log("================================"); console.log("Secret Key:", SECRET_KEY); console.log("Test Message:", TEST_MESSAGE); console.log(""); try { // Test encryption console.log("๐Ÿ” Encrypting message..."); const encrypted = encryptMessage(TEST_MESSAGE, SECRET_KEY); console.log("Encrypted:", encrypted); console.log(""); // Test decryption console.log("๐Ÿ”“ Decrypting message..."); const decrypted = decryptMessage(encrypted, SECRET_KEY); console.log("Decrypted:", decrypted); console.log(""); // Test results if (decrypted === TEST_MESSAGE) { console.log("โœ… Encryption/Decryption test PASSED!"); } else { console.log("โŒ Encryption/Decryption test FAILED!"); console.log("Expected:", TEST_MESSAGE); console.log("Got:", decrypted); } console.log(""); console.log("To test with Flutter:"); console.log("1. Use this encrypted text in Flutter:", encrypted); console.log("2. See if Flutter can decrypt it to:", TEST_MESSAGE); console.log(""); // Test with some sample encrypted text from Flutter (if provided) // You can add sample encrypted messages from Flutter here to test compatibility } catch (error) { console.error("โŒ Test failed with error:", error); }