瀏覽代碼

Tidied operations to match conventions

Matt C 8 年之前
父節點
當前提交
a153246191
共有 4 個文件被更改,包括 26 次插入6 次删除
  1. 3 3
      src/js/config/Categories.js
  2. 3 3
      src/js/config/OperationConfig.js
  3. 14 0
      src/js/core/Utils.js
  4. 6 0
      src/js/operations/Cipher.js

+ 3 - 3
src/js/config/Categories.js

@@ -66,9 +66,6 @@ var Categories = [
         ops: [
         ops: [
             "AES Encrypt",
             "AES Encrypt",
             "AES Decrypt",
             "AES Decrypt",
-            "Affine Cipher Encode",
-            "Affine Cipher Decode",
-            "Atbash Cipher",
             "Blowfish Encrypt",
             "Blowfish Encrypt",
             "Blowfish Decrypt",
             "Blowfish Decrypt",
             "DES Encrypt",
             "DES Encrypt",
@@ -87,6 +84,9 @@ var Categories = [
             "Vigenère Decode",
             "Vigenère Decode",
             "To Morse Code",
             "To Morse Code",
             "From Morse Code",
             "From Morse Code",
+            "Affine Cipher Encode",
+            "Affine Cipher Decode",
+            "Atbash Cipher",
             "Substitute",
             "Substitute",
             "Derive PBKDF2 key",
             "Derive PBKDF2 key",
             "Derive EVP key",
             "Derive EVP key",

+ 3 - 3
src/js/config/OperationConfig.js

@@ -1361,7 +1361,7 @@ var OperationConfig = {
         ]
         ]
     },
     },
     "Affine Cipher Encode": {
     "Affine Cipher Encode": {
-        description: "The affine cipher is a type of monoalphabetic substitution cipher, wherein each letter in an alphabet is mapped to its numeric equivalent, encrypted using simple mathematical function (ax + b) % 26, and converted back to a letter.",
+        description: "The Affine cipher is a type of monoalphabetic substitution cipher, wherein each letter in an alphabet is mapped to its numeric equivalent, encrypted using simple mathematical function (ax + b) % 26, and converted back to a letter.",
         run: Cipher.runAffineEnc,
         run: Cipher.runAffineEnc,
         highlight: true,
         highlight: true,
         highlightReverse: true,
         highlightReverse: true,
@@ -1381,7 +1381,7 @@ var OperationConfig = {
         ]
         ]
     },
     },
     "Affine Cipher Decode": {
     "Affine Cipher Decode": {
-        description: "The affine cipher is a type of monoalphabetic substitution cipher. To decrypt, each letter in an alphabet is mapped to its numeric equivalent, decrypted by a mathematical function, and converted back to a letter.",
+        description: "The Affine cipher is a type of monoalphabetic substitution cipher. To decrypt, each letter in an alphabet is mapped to its numeric equivalent, decrypted by a mathematical function, and converted back to a letter.",
         run: Cipher.runAffineDec,
         run: Cipher.runAffineDec,
         highlight: true,
         highlight: true,
         highlightReverse: true,
         highlightReverse: true,
@@ -1401,7 +1401,7 @@ var OperationConfig = {
         ]
         ]
     },
     },
     "Atbash Cipher": {
     "Atbash Cipher": {
-        description: "Atbash is a mono-alphabetic substitution cipher originally used to encode the Hebrew alphabet. It has been modified here for use with the latin alphabet.",
+        description: "Atbash is a mono-alphabetic substitution cipher originally used to encode the Hebrew alphabet. It has been modified here for use with the Latin alphabet.",
         run: Cipher.runAtbash,
         run: Cipher.runAtbash,
         highlight: true,
         highlight: true,
         highlightReverse: true,
         highlightReverse: true,

+ 14 - 0
src/js/core/Utils.js

@@ -927,8 +927,11 @@ var Utils = {
                 a[key] = b[key];
                 a[key] = b[key];
         return a;
         return a;
     },
     },
+
+
     /**
     /**
      * Actual modulo function, since % is actually the remainder function in JS
      * Actual modulo function, since % is actually the remainder function in JS
+     *
      * @author Matt C [matt@artemisbot.pw]
      * @author Matt C [matt@artemisbot.pw]
      * @param {number} x
      * @param {number} x
      * @param {number} y
      * @param {number} y
@@ -937,8 +940,10 @@ var Utils = {
         return ((x % y) + y) % y;
         return ((x % y) + y) % y;
     },
     },
 
 
+
     /**
     /**
      * Finds GCD of two numbers
      * Finds GCD of two numbers
+     *
      * @author Matt C [matt@artemisbot.pw]
      * @author Matt C [matt@artemisbot.pw]
      * @param {number} x
      * @param {number} x
      * @param {number} y
      * @param {number} y
@@ -950,6 +955,14 @@ var Utils = {
         return Utils.gcd(y, x % y);
         return Utils.gcd(y, x % y);
     },
     },
 
 
+
+    /**
+     * Finds modular inverse of two values
+     *
+     * @author Matt C [matt@artemisbot.pw]
+     * @param {number} x
+     * @param {number} y
+     */
     modInv: function(x, y) {
     modInv: function(x, y) {
         x %= y;
         x %= y;
         for (var i = 1; i < y; i++) {
         for (var i = 1; i < y; i++) {
@@ -959,6 +972,7 @@ var Utils = {
         }
         }
     },
     },
 
 
+
     /**
     /**
      * A mapping of names of delimiter characters to their symbols.
      * A mapping of names of delimiter characters to their symbols.
      * @constant
      * @constant

+ 6 - 0
src/js/operations/Cipher.js

@@ -385,6 +385,7 @@ var Cipher = {
         return encrypted.ciphertext.toString(Utils.format[args[2]]);
         return encrypted.ciphertext.toString(Utils.format[args[2]]);
     },
     },
 
 
+
     /**
     /**
      * Vigenère Encode operation.
      * Vigenère Encode operation.
      *
      *
@@ -474,6 +475,7 @@ var Cipher = {
         return output;
         return output;
     },
     },
 
 
+
     /**
     /**
      * @constant
      * @constant
      * @default
      * @default
@@ -484,6 +486,7 @@ var Cipher = {
      * @default
      * @default
      */
      */
     AFFINE_B: 0,
     AFFINE_B: 0,
+
     /**
     /**
      * Affine Cipher Encode operation.
      * Affine Cipher Encode operation.
      *
      *
@@ -513,6 +516,7 @@ var Cipher = {
         return output;
         return output;
     },
     },
 
 
+
     /**
     /**
      * Affine Cipher Encode operation.
      * Affine Cipher Encode operation.
      *
      *
@@ -546,6 +550,7 @@ var Cipher = {
         return output;
         return output;
     },
     },
 
 
+
     /**
     /**
      * Atbash Cipher Encode operation.
      * Atbash Cipher Encode operation.
      *
      *
@@ -558,6 +563,7 @@ var Cipher = {
         return Cipher.runAffineEnc(input, [25, 25]);
         return Cipher.runAffineEnc(input, [25, 25]);
     },
     },
 
 
+
     /**
     /**
      * @constant
      * @constant
      * @default
      * @default