const crypto = require('crypto');
function hashSHA256(input) {
const hash = crypto.createHash('sha256');
hash.update(input);
return hash.digest('hex');
}
// Example usage
const email = 'example@example.com';
const phone = '+1234567890';
// Hash email
const emailHash = hashSHA256(email);
console.log('Hashed email:', emailHash);
// Hash phone number
const phoneHash = hashSHA256(phone);
console.log('Hashed phone number:', phoneHash);
const crypto = require('crypto');
function main() {
const partnerId = "YOUR-VALID-PARTNER-ID";
const partnerSecret = "8d8dd8af95971d949f4c6a941bc86696";
const emailHash = hashSHA256("user@email.com");
const phoneHash = hashSHA256("085123456789");
const payload = {
partnerId,
emailHash,
phoneHash
};
try {
const jsonString = JSON.stringify(payload);
const encryptedPayload = encrypt(jsonString, partnerSecret);
console.log(encryptedPayload);
} catch (error) {
console.error('Encryption error:', error);
}
}
function encrypt(str, secret) {
const key = Buffer.from(secret, 'hex');
const cipher = crypto.createCipheriv('aes-128-cfb', key, key);
let encrypted = cipher.update(str, 'utf8', 'base64');
encrypted += cipher.final('base64');
return encrypted;
}
main();