-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsuper-encoder.js
43 lines (36 loc) · 1.2 KB
/
super-encoder.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
// Import the encryptors functions here.
const {caesarCipher, symbolCipher, reverseCipher} = require("./encryptors");
const encodeMessage = (str) => {
// Use the encryptor functions here.
let first = caesarCipher(str, 13);
let second = symbolCipher(first);
let third = caesarCipher(second, 13);
let fourth = reverseCipher(third);
let fifth = caesarCipher(fourth, 11);
return fifth;
}
const decodeMessage = (str) => {
// Use the encryptor functions here.
let fifth = caesarCipher(str, -11);
let fourth = reverseCipher(fifth);
let third = caesarCipher(fourth, -13);
let second = symbolCipher(third);
let first = caesarCipher(second, -13);
return first
}
// User input / output.
const handleInput = (userInput) => {
const str = userInput.toString().trim();
let output;
if (process.argv[2] === 'encode') {
output = encodeMessage(str);
}
if (process.argv[2] === 'decode') {
output = decodeMessage(str);
}
process.stdout.write(output + '\n');
process.exit();
}
// Run the program.
process.stdout.write('Enter the message you would like to encrypt...\n> ');
process.stdin.on('data', handleInput);