-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlib.js
More file actions
39 lines (38 loc) · 909 Bytes
/
lib.js
File metadata and controls
39 lines (38 loc) · 909 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
34
35
36
37
38
39
module.exports = {
encryptValue : 10,
encrypt : function(msg,value){
if(value === undefined){
value = this.encryptValue;
}
var msgArr = msg.split("");
for(var loop = 0; loop < msgArr.length; loop++){
msgArr[loop] = String.fromCharCode(msgArr[loop].charCodeAt() + value);
}
msg = msgArr.join("");
return msg
},
decrypt : function(msg){
return this.encrypt(msg, this.encryptValue*-1);
},
file : {
read : function(fileName,callback){
fs = require('fs')
fs.readFile('./' + fileName, 'utf8', function (err,data) {
if (err) {
return console.log(err);
}
callback(data);
});
},
write : function(fileName,content){
var fs = require('fs');
fs.writeFile(fileName, content, function(err) {
if(err) {
console.log(err);
} else {
console.log("The file was saved!");
}
});
}
}
}