Fix database setup, test encryption and repositories - all working

Co-authored-by: southseact-3d <217551146+southseact-3d@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2026-02-09 19:37:28 +00:00
parent 650d849ad2
commit fd6d2d641b
7 changed files with 539 additions and 20 deletions

33
chat/test-encryption.js Normal file
View File

@@ -0,0 +1,33 @@
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!');