-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
58 lines (52 loc) · 1.31 KB
/
index.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
'use strict'
const init = require('./cmds/init')
const encrypt = require('./cmds/encrypt')
const decrypt = require('./cmds/decrypt')
const encryptor = require('file-encryptor')
const md5 = require('md5');
const path = require('path');
const fs = require('fs')
const vorpal = require('vorpal')();
let appConfig = {
password: md5('password'),
key: 'blablabla'
}
vorpal
.command('password', 'Password')
.alias('pass', 'p')
.action(function(args, callback) {
const self = this;
let files = fs.readdirSync('files')
self.log(typeof files)
self.prompt({
type: 'password',
name: 'password',
message: 'password ? '
}, function(result){
self.log(result)
if(md5(result.password) !== appConfig.password) {
self.log('Bad password')
} else {
self.log('It\'s ok for you')
self.prompt({
type: 'password',
name: 'password',
message: 'password ? '
}, function(result){
self.log(result)
if(md5(result.password) !== appConfig.password) {
self.log('Bad password')
} else {
self.log('It\'s ok for you')
}
})
}
})
this.log('args', args);
});
vorpal
.delimiter('memoryEncryptor $')
.use(init)
.use(encrypt)
.use(decrypt)
.show();