const crypto = require('crypto');

function generateSmtpPassword(secretAccessKey) {
  const message = "SendRawEmail";
  const version = Buffer.from([0x02]);
  const key = Buffer.from(secretAccessKey, 'utf-8');
  const hmac = crypto.createHmac('sha256', key).update(message).digest();
  const smtpPassword = Buffer.concat([version, hmac]).toString('base64');
  return smtpPassword;
}

// Use your actual AWS Secret Access Key here (NOT the Access Key ID)
const smtpPassword = generateSmtpPassword('wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY');
console.log('SMTP Password:', smtpPassword);
