forked from yusufusta/WhatsAsena
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStringSession.js
35 lines (27 loc) · 934 Bytes
/
StringSession.js
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
/* Copyright (C) 2020 Yusuf Usta.
Licensed under the GPL-3.0 License;
you may not use this file except in compliance with the License.
WhatsAsena - Yusuf Usta
*/
const fs = require('fs');
class StringSession {
constructor() {
}
deCrypt(string = undefined) {
if ('ASENA_SESSION' in process.env && string === undefined) {
string = process.env.STRING_SESSION;
} else if (string !== undefined) {
if (fs.existsSync(string)) {
string = fs.readFileSync(string, {encoding:'utf8', flag:'r'});
}
}
var split = string.split(';;;');
if (split.length >= 2) {
return JSON.parse(Buffer.from(split[split.length - 1], 'base64').toString('utf-8'));
}
}
createStringSession(dict) {
return 'ASENA;;;' + Buffer.from(JSON.stringify(dict)).toString('base64');
}
}
module.exports = StringSession;