Skip to content

Commit 59e2fbd

Browse files
authored
Merge pull request ashutosh97#77 from benlop27/master
Added Cenit Polar Crypto
2 parents 7239b65 + bf7b707 commit 59e2fbd

File tree

2 files changed

+61
-0
lines changed

2 files changed

+61
-0
lines changed

Cenit-Polar-Crypt/Issue.txt

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
Create a solution that can be able to encrypt a string using Cenit-Polar Method
2+
3+
- Solution
4+
Cenit Polar it's a basic scout crytographic method based on replace characters
5+
corresponding this order :
6+
-------------------------
7+
| C | E | N | I | T |
8+
-------------------------
9+
| P | O | L | A | R |
10+
-------------------------
11+
12+
The main idea is take a word and replace the characters which match in CENIT, with its equivalent on POLAR and viceversa.
13+
14+
For example, if you want to encrypt the word COMPUTER, you should have to replace any character.
15+
If some character don't have match, you should keep it in place:
16+
17+
C = P
18+
O = E
19+
M = M
20+
P = C
21+
U = U
22+
T = R
23+
E = O
24+
R = T
25+
26+
If you want to decript the word generated, you have to do reverse the process, replacing any character which have match in POLAR,
27+
with its equivalent on CENIT :
28+
29+
P = C
30+
E = O
31+
M = M
32+
C = P
33+
U = U
34+
R = T
35+
O = E
36+
T = R
37+
38+
Cenit - Polar makes this alphabet table:
39+
A B C D E F G H I J K L M N Ñ O P Q R S T U V W X Y Z
40+
I B P D O F G H A J K N M L Ñ E C Q T S R U V W X Y Z

Cenit-Polar-Crypt/Solution.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
2+
function processWord(encryptedWord){
3+
let splitedText = (encryptedWord.toLowerCase()).split("");
4+
let cenit = ["c", "e", "n", "i", "t"];
5+
var polar = ["p", "o", "l", "a", "r"];
6+
var encryptWordArray = [];
7+
splitedText.map(function(i) {
8+
if (cenit.indexOf(i) > -1) {
9+
i = polar[cenit.indexOf(i)];
10+
encryptWordArray.push(i);
11+
} else if (polar.indexOf(i) > -1) {
12+
i = cenit[polar.indexOf(i)];
13+
encryptWordArray.push(i);
14+
} else {
15+
encryptWordArray.push(i);
16+
}
17+
});
18+
return encryptWordArray.join("").toUpperCase();
19+
}
20+
21+
console.log(processWord("COMPUTER"));

0 commit comments

Comments
 (0)