js-caesarcipher 1.0.4 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -9,6 +9,8 @@ Add this script tag to your html code
9
9
 
10
10
  # Useage
11
11
 
12
+ **Cipher the text**
13
+
12
14
  Use the function `new CaesarCipher()`
13
15
 
14
16
  Example: "Hello World", after shifting 2 letters will be "Jgnnq Yqtnf"
@@ -24,3 +26,20 @@ console.log(cipher.result);
24
26
 
25
27
  * The `input` is unciphered plain text.
26
28
  * The `shift` is shift how many letters.
29
+
30
+ **Decipher the text**
31
+
32
+ Use the function `CaesarCipher.deCipher()`
33
+
34
+ ```javascript
35
+ CaesarCipher.deCipher("Jgnnq Yqtnf", 2)
36
+ // The output will be "Hello World"
37
+ ```
38
+
39
+ **Crack ciphered text**
40
+
41
+ Use the function `CaesarCipher.crack()`
42
+
43
+ ```javascript
44
+ CaesarCipher.crack("Jgnnq Yqtnf")
45
+ ```
package/index.html CHANGED
@@ -1,4 +1,5 @@
1
1
  <script src="script.js"></script>
2
2
  <script>
3
-
3
+
4
+ console.table(CaesarCipher.crack("Jgnnq Yqtnf"))
4
5
  </script>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "js-caesarcipher",
3
- "version": "1.0.4",
3
+ "version": "1.1.1",
4
4
  "description": "A JavaScript library for Caesar Cipher",
5
5
  "keywords": [
6
6
  "caesar cipher",
package/script.js CHANGED
@@ -23,3 +23,23 @@ function CaesarCipher({ input, shift }) {
23
23
  }
24
24
  this.result = result;
25
25
  }
26
+
27
+ CaesarCipher.deCipher = function (encryptedText, shifted) {
28
+ let decipher = new CaesarCipher({
29
+ "input": encryptedText,
30
+ "shift": shifted * -1
31
+ });
32
+ return decipher.result;
33
+ }
34
+
35
+ CaesarCipher.crack = function (encryptedText) {
36
+ let allShifts = []
37
+ for (let i = 0; i < 26; i++) {
38
+ let shift = new CaesarCipher({
39
+ "input": encryptedText,
40
+ "shift": i
41
+ });
42
+ allShifts.push(shift.result)
43
+ }
44
+ return allShifts
45
+ }