const { initEncryption, encrypt, decrypt, hashValue, verifyHash } = require('./src/utils/encryption'); const crypto = require('crypto'); // Initialize const key = crypto.randomBytes(32).toString('hex'); initEncryption(key); console.log('šŸ” Testing Encryption...\n'); // Test 1: Basic encryption/decryption const plaintext = 'test@example.com'; const encrypted = encrypt(plaintext); const decrypted = decrypt(encrypted); console.log('Test 1: Basic Encryption'); console.log(' Plaintext:', plaintext); console.log(' Encrypted:', encrypted.substring(0, 50) + '...'); console.log(' Decrypted:', decrypted); console.log(' Match:', plaintext === decrypted ? 'āœ…' : 'āŒ'); // Test 2: Hash and verify const value = 'mytoken123'; const { hash, salt } = hashValue(value); const isValid = verifyHash(value, hash, salt); const isInvalid = verifyHash('wrongvalue', hash, salt); console.log('\nTest 2: Hash and Verify'); console.log(' Value:', value); console.log(' Hash:', hash.substring(0, 30) + '...'); console.log(' Valid verification:', isValid ? 'āœ…' : 'āŒ'); console.log(' Invalid verification:', !isInvalid ? 'āœ…' : 'āŒ'); console.log('\nāœ… All encryption tests passed!');