29 lines
876 B
JavaScript
29 lines
876 B
JavaScript
const dominios = ['gmail.com', 'yahoo.com', 'hotmail.com', 'example.com', 'test.org'];
|
|
|
|
const emails = Array.from({ length: 100 }, () => {
|
|
const usuario = Math.random().toString(36).substring(2, 10);
|
|
const dominio = dominios[randomInt(0, dominios.length - 1)];
|
|
return usuario + '@' + dominio;
|
|
});
|
|
|
|
function randomInt(min, max) {
|
|
return Math.floor(Math.random() * (max - min + 1)) + min;
|
|
}
|
|
|
|
function enmascarado(mail) {
|
|
const indice = mail.indexOf("@"),
|
|
corte = mail.slice(0, indice),
|
|
corteCentral = corte.slice(1, corte.length - 1);
|
|
|
|
return corte[0] + "*".repeat(corteCentral.length) + corte[corte.length - 1] + mail.slice(indice);
|
|
}
|
|
|
|
const emailSeleccionado = emails[randomInt(0, emails.length - 1)];
|
|
|
|
console.log('emailSeleccionado', emailSeleccionado);
|
|
|
|
const emailEnmascarado = enmascarado(emailSeleccionado);
|
|
|
|
console.log('emailEnmascarado', emailEnmascarado)
|
|
|