-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.js
More file actions
96 lines (83 loc) · 2.72 KB
/
Copy pathindex.js
File metadata and controls
96 lines (83 loc) · 2.72 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
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
86
87
88
89
90
91
92
93
94
95
fs = require('fs');
var arglist = [];
var encText ="";
var text="";
var er = false;
function output(){
if(arglist.indexOf("C")==-1 && arglist.indexOf("O")==-1){
console.error("You have to specify an output method, idiot")
}
if(arglist.indexOf("C")!==-1){
console.log(encText);
}
if(arglist.indexOf("O"!==-1)){
fs.writeFile(arglist[arglist.indexOf("O")+1],encText,function(err){
// if(err){
// throw(err)
// }
})
}
}
function encrypt(t){
var temp = ""
if(arglist.indexOf("E")!==-1){
for(i in t){
temp=temp+t[i].charCodeAt()+"|";
}
temp=temp.slice(0,temp.length-1);
return(temp);
}else if(arglist.indexOf("U")!==-1){
var temparr = t.split("|");
for(i in temparr){
temp = temp+String.fromCharCode(Number(temparr[i]));
}
console.log(temp);
return(temp);
}
}
function decrypt(t){
}
function split(arr,size){
chunkSize = size;
chunks = [];
for (let i = 0; i < arr.length; i += chunkSize) {
const chunk = arr.slice(i, i + chunkSize);
chunks.push(chunk);
}
return(chunks);
}
process.argv.forEach((val,index)=>{arglist.push(val);});
// console.log(arglist);
if(arglist[2]=="help" || arglist[2]=="/?"||arglist.length==2){
console.log("index.js {[T text] [F filename]} [C] [O filename] {[U]|[E]} [help|/?] ")
console.log(" T text The text to be en/decrypted.");
console.log(" F filename The filename of the txt file to be en/decrypted.");
console.log(" C Print the en/decrypted text to the console.");
console.log(" O filename The filename of the en/decrypted txt file to be created.");
console.log(" U Decrypt the text.");
console.log(" E Encrypt the text.");
console.log(" help|/? Shows this help message.")
}else{
if(arglist.indexOf("T")==-1 && arglist.indexOf("F")==-1){
console.error("You have to specify an input method, idiot")
}else if(arglist.indexOf("T")!==-1 && arglist.indexOf("F")!==-1){
console.error("You can't have T and F as arguments at the same time, dumbass!")
}else if(arglist.indexOf("F")!==-1){
fs.readFile(arglist[arglist.indexOf("F")+1],function(err,html){
if(err){
throw(err);
}
text=html.toString();
encText=encrypt(text);
console.log(encText);
output();
// console.log(html.toString());
})
}else if(arglist.indexOf("T")!==-1){
text=arglist[arglist.indexOf("T")+1];
encText=encrypt(text);
output();
}
console.log("the text is:" + text);
}
// console.log(arglist);