js-caesarcipher 1.0.3 → 1.1.0

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.
Files changed (3) hide show
  1. package/index.html +2 -1
  2. package/package.json +1 -1
  3. package/script.js +21 -1
package/index.html CHANGED
@@ -1,4 +1,5 @@
1
1
  <script src="script.js"></script>
2
2
  <script>
3
-
3
+
4
+ console.log(CaesarCipher.crack("Jgnnq Yqtnf", 2))
4
5
  </script>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "js-caesarcipher",
3
- "version": "1.0.3",
3
+ "version": "1.1.0",
4
4
  "description": "A JavaScript library for Caesar Cipher",
5
5
  "keywords": [
6
6
  "caesar cipher",
package/script.js CHANGED
@@ -22,4 +22,24 @@ function CaesarCipher({ input, shift }) {
22
22
  }
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
+ }