فهرست منبع

Added 'Substitute' operation.

n1474335 8 سال پیش
والد
کامیت
ef464ab57c

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 0 - 0
build/prod/cyberchef.htm


تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 0 - 0
build/prod/index.html


تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 0 - 0
build/prod/scripts.js


+ 1 - 0
src/js/config/Categories.js

@@ -82,6 +82,7 @@ const Categories = [
             "XOR Brute Force",
             "Vigenère Encode",
             "Vigenère Decode",
+            "Substitute",
             "Derive PBKDF2 key",
             "Derive EVP key",
         ]

+ 18 - 0
src/js/config/OperationConfig.js

@@ -2863,5 +2863,23 @@ const OperationConfig = {
         input_type: "string",
         output_type: "string",
         args: []
+    },
+    "Substitute": {
+        description: "A substitution cipher allowing you to specify bytes to replace with other byte values. This can be used to create Caesar ciphers but is more powerful as any byte value can be substituted, not just letters, and the substitution values need not be in order.<br><br>Enter the bytes you want to replace in the Plaintext field and the bytes to replace them with in the Ciphertext field.<br><br>Non-printable bytes can be specified using string escape notation. For example, a line feed character can be written as either <code>\\n</code> or <code>\\x0a</code>.<br><br>Byte ranges can be specified using a hyphen. For example, the sequence <code>0123456789</code> can be written as <code>0-9</code>.",
+        run: Cipher.run_substitute,
+        input_type: "byte_array",
+        output_type: "byte_array",
+        args: [
+            {
+                name: "Plaintext",
+                type: "binary_string",
+                value: Cipher.SUBS_PLAINTEXT
+            },
+            {
+                name: "Ciphertext",
+                type: "binary_string",
+                value: Cipher.SUBS_CIPHERTEXT
+            }
+        ]
     }
 };

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

@@ -475,6 +475,43 @@ var Cipher = {
         return output;
     },
 
+
+    /**
+     * @constant
+     * @default
+     */
+    SUBS_PLAINTEXT: "ABCDEFGHIJKLMNOPQRSTUVWXYZ",
+    /**
+     * @constant
+     * @default
+     */
+    SUBS_CIPHERTEXT: "XYZABCDEFGHIJKLMNOPQRSTUVW",
+
+    /**
+     * Substitute operation.
+     *
+     * @param {byte_array} input
+     * @param {Object[]} args
+     * @returns {byte_array}
+     */
+    run_substitute: function (input, args) {
+        var plaintext = Utils.str_to_byte_array(Utils.expand_alph_range(args[0]).join()),
+            ciphertext = Utils.str_to_byte_array(Utils.expand_alph_range(args[1]).join()),
+            output = [],
+            index = -1;
+
+        if (plaintext.length !== ciphertext.length) {
+            output = Utils.str_to_byte_array("Warning: Plaintext and Ciphertext lengths differ\n\n");
+        }
+
+        for (var i = 0; i < input.length; i++) {
+            index = plaintext.indexOf(input[i]);
+            output.push(index > -1 && index < ciphertext.length ? ciphertext[index] : input[i]);
+        }
+
+        return output;
+    },
+
 };
 
 

+ 4 - 4
src/static/stats.txt

@@ -1,9 +1,9 @@
 206	source files
-113355	lines
+113411	lines
 4.2M	size
 
 137	JavaScript source files
-104197	lines
+104253	lines
 3.7M	size
 
 79	third party JavaScript source files
@@ -11,11 +11,11 @@
 3.0M	size
 
 58	first party JavaScript source files
-19145	lines
+19201	lines
 724K	size
 
 3.4M	uncompressed JavaScript size
 1.8M	compressed JavaScript size
 
 15	categories
-157	operations
+158	operations

برخی فایل ها در این مقایسه diff نمایش داده نمی شوند زیرا تعداد فایل ها بسیار زیاد است