-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
46 lines (41 loc) · 1.02 KB
/
Copy pathserver.js
File metadata and controls
46 lines (41 loc) · 1.02 KB
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
const express = require("express");
const app = express();
app.use(express.urlencoded({ extended: true }));
app.use("/", express.static(__dirname + "/public"));
app.set("view engine", "hbs");
app.post("/run", (req, res) => {
let decryptedData = decrypt(req.body.encryptedData);
let decodedData = new Buffer(decryptedData, "base64")
.toString("ascii")
.trim();
let output;
try {
output = eval(decodedData);
} catch (err) {
output = err;
}
res.render("result", {
output,
decodedData,
});
});
app.listen(3000, () => {
console.log("Server is Running...");
});
function decrypt(data) {
let newData = "";
for (let i = 0; i < data.length; i++) {
//check lower
let item = data[i];
if (data[i] != data[i].toUpperCase() && data[i] === data[i].toLowerCase()) {
item = data[i].toUpperCase();
} else if (
data[i] != data[i].toLowerCase() &&
data[i] === data[i].toUpperCase()
) {
item = data[i].toLowerCase();
}
newData += item;
}
return newData;
}