forked from Abdulqudus001/ceasers-cipher
-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathmain.js
More file actions
33 lines (28 loc) · 945 Bytes
/
main.js
File metadata and controls
33 lines (28 loc) · 945 Bytes
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
const checkbox = document.querySelector('#check');
const label = document.querySelector('.check__text');
const input = document.querySelector('#input');
const output = document.querySelector('#output');
const alphabets = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j',
'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't',
'u', 'v', 'w', 'x', 'y', 'z'];
let cipherText = '';
window.addEventListener('load', () => {
const runAlgorithm = (() => {
let text = input.value;
input.addEventListener('input', (key) => {
text = input.value;
let checked = checkbox.checked;
output.textContent = !checked ? encrypt(text) : decrypt(text);
});
})();
const encrypt = (text) => {
return text;
};
const decrypt = (text) => {
return text;
};
checkbox.addEventListener('change', (e) => {
let checked = e.target.checked;
label.textContent = !checked ? 'Encrypting...' : 'Decrypting...';
});
});