-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathencrypt.js
executable file
·28 lines (24 loc) · 933 Bytes
/
encrypt.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
(async function () {
const prompts = require('prompts');
const prompt = await prompts([
{
type: 'text',
name: 'message',
message: 'Message:'
}, {
type: 'text',
name: 'publicKey',
message: 'Public key:'
}
]);
const stringToKey = require('./modules/stringToKey.js');
const message = prompt.message;
const publicKey = stringToKey(prompt.publicKey, false);
//console.log({message,publicKey});
const stringToAsciiArray = require('./modules/stringToAsciiArray.js');
const encryptAsciiArray = require('./modules/encryptAsciiArray.js');
const numArrayToString = require('./modules/numArrayToString.js');
console.log('\n');
console.log('\x1b[32m%s\x1b[0m',numArrayToString(encryptAsciiArray(stringToAsciiArray(message), publicKey).map(n => n.toString())));
console.log('\n');
})();