-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
27 lines (22 loc) · 985 Bytes
/
script.js
File metadata and controls
27 lines (22 loc) · 985 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
function encode() {
const inputText = document.getElementById('inputText').value;
const decodingWord = document.getElementById('decodingWord').value.toLowerCase();
let encodedText = '';
for (let i = 0; i < inputText.length; i++) {
const charCode = inputText.charCodeAt(i);
const newCharCode = charCode + decodingWord.length;
encodedText += String.fromCharCode(newCharCode);
}
document.getElementById('outputText').value = encodedText;
}
function decode() {
const inputText = document.getElementById('inputText').value;
const decodingWord = document.getElementById('decodingWord').value.toLowerCase();
let decodedText = '';
for (let i = 0; i < inputText.length; i++) {
const charCode = inputText.charCodeAt(i);
const originalCharCode = charCode - decodingWord.length;
decodedText += String.fromCharCode(originalCharCode);
}
document.getElementById('outputText').value = decodedText;
}