-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEncriptador.js
85 lines (73 loc) · 1.91 KB
/
Encriptador.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
//var texto="";
var caja = [];
var vocales = ["a", "e", "i", "o", "u"];
var intercambio = ["ai", "enter", "imes", "ober", "ufat"];
var verificar = false;
var texto = "";
var cnt = 0;
const canva = document.getElementById("lienzo2");
const ct = canva.getContext("2d");
const wi = canva.width;
const he = canva.height;
ctx.fillRect(0, 0, wi, he);
const col = Math.floor(wi / 20) + 1;
const position_y = Array(col).fill(0);
function encriptar() {
var input = document.getElementById("mensajeaEncriptar");
texto = input.value;
verificarMinusculas(texto);
if (verificar) {
for (let i = 0; i < texto.length; i++) {
caja.push(texto[i]);
for (let j = 0; j < vocales.length; j++) {
if (caja[i] == vocales[j]) {
caja[i] = intercambio[j];
}
}
}
function matrix() {
ct.fillStyle = "#0001";
ct.fillRect(0, 0, wi, he);
ct.fillStyle = "#78C3D7";
ct.font = "15pt monospace";
position_y.forEach((y, ind) => {
const text = String.fromCharCode(Math.random() * 128);
const x = ind * 20;
ct.fillText(text, x, y);
if (y > 100 + Math.random() * 1000) {
position_y[ind] = 0;
} else position_y[ind] = y + 20;
});
cnt++;
if (cnt == 60) {
clearInterval(intervalo);
ct.fillStyle = "#77C4D6";
ct.fillRect(0, 0, wi, he);
cnt = 0;
juntar();
}
}
var intervalo = setInterval(matrix, Math.random() * 50);
} else {
alert("Ingrese solo minúsculas");
}
}
function verificarMinusculas(texto) {
let mayusculas = /^[a-z\s]+$/g;
verificar = mayusculas.test(texto);
console.log(verificar);
return verificar;
}
function juntar() {
let nueva = "";
for (let k = 0; k < caja.length; k++) {
nueva = nueva.concat(caja[k]);
}
resultado.innerText = nueva;
reiniciarValores();
}
function reiniciarValores() {
caja = [];
texto = "";
nueva = "";
}