-
Notifications
You must be signed in to change notification settings - Fork 0
/
encriptar.js
40 lines (32 loc) · 1.26 KB
/
encriptar.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
const inputTexto = document.querySelector(".inputTexto")
const mensaje = document.querySelector(".mensaje")
function btnEncriptar(){
const codificado = encriptar(inputTexto.value)
mensaje.value = codificado;
inputTexto.value = ""
}
function encriptar(stringEncriptar){
let codificar = [["e", "enter"],["i","imes"],["a","ai"],["o","ober"],["u","ufat"]];
stringEncriptar = stringEncriptar.toLowerCase();
for( let i = 0; i<codificar.length; i++){
if(stringEncriptar.includes(codificar[i][0])){
stringEncriptar = stringEncriptar.replaceAll(codificar[i][0],codificar[i][1])
}
}
return stringEncriptar
}
function btnDesencriptar(){
const codificado = desencriptar(inputTexto.value)
mensaje.value = codificado;
inputTexto.value = ""
}
function desencriptar(stringDesencriptar){
let decodificar = [["a","ai"],["e", "enter"],["i","imes"],["o","ober"],["u","ufat"]];
stringDesencriptar = stringDesencriptar.toLowerCase();
for( let i = 0; i<decodificar.length; i++){
if(stringDesencriptar.includes(decodificar[i][1])){
stringDesencriptar = stringDesencriptar.replaceAll(decodificar[i][1],decodificar[i][0])
}
}
return stringDesencriptar
}