From a15324619140f9acf626fc409d006589b9a97239 Mon Sep 17 00:00:00 2001 From: Matt C Date: Wed, 8 Feb 2017 17:29:50 +0000 Subject: [PATCH] Tidied operations to match conventions --- src/js/config/Categories.js | 6 +++--- src/js/config/OperationConfig.js | 6 +++--- src/js/core/Utils.js | 14 ++++++++++++++ src/js/operations/Cipher.js | 6 ++++++ 4 files changed, 26 insertions(+), 6 deletions(-) diff --git a/src/js/config/Categories.js b/src/js/config/Categories.js index 6670c417..a1aa43de 100755 --- a/src/js/config/Categories.js +++ b/src/js/config/Categories.js @@ -66,9 +66,6 @@ var Categories = [ ops: [ "AES Encrypt", "AES Decrypt", - "Affine Cipher Encode", - "Affine Cipher Decode", - "Atbash Cipher", "Blowfish Encrypt", "Blowfish Decrypt", "DES Encrypt", @@ -87,6 +84,9 @@ var Categories = [ "Vigenère Decode", "To Morse Code", "From Morse Code", + "Affine Cipher Encode", + "Affine Cipher Decode", + "Atbash Cipher", "Substitute", "Derive PBKDF2 key", "Derive EVP key", diff --git a/src/js/config/OperationConfig.js b/src/js/config/OperationConfig.js index 6dfc0913..8bb215a8 100755 --- a/src/js/config/OperationConfig.js +++ b/src/js/config/OperationConfig.js @@ -1361,7 +1361,7 @@ var OperationConfig = { ] }, "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, highlight: true, highlightReverse: true, @@ -1381,7 +1381,7 @@ var OperationConfig = { ] }, "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, highlight: true, highlightReverse: true, @@ -1401,7 +1401,7 @@ var OperationConfig = { ] }, "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, highlight: true, highlightReverse: true, diff --git a/src/js/core/Utils.js b/src/js/core/Utils.js index 3924daa1..984389b1 100755 --- a/src/js/core/Utils.js +++ b/src/js/core/Utils.js @@ -927,8 +927,11 @@ var Utils = { a[key] = b[key]; return a; }, + + /** * Actual modulo function, since % is actually the remainder function in JS + * * @author Matt C [matt@artemisbot.pw] * @param {number} x * @param {number} y @@ -937,8 +940,10 @@ var Utils = { return ((x % y) + y) % y; }, + /** * Finds GCD of two numbers + * * @author Matt C [matt@artemisbot.pw] * @param {number} x * @param {number} y @@ -950,6 +955,14 @@ var Utils = { 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) { x %= y; for (var i = 1; i < y; i++) { @@ -959,6 +972,7 @@ var Utils = { } }, + /** * A mapping of names of delimiter characters to their symbols. * @constant diff --git a/src/js/operations/Cipher.js b/src/js/operations/Cipher.js index a1aba487..9e411cff 100755 --- a/src/js/operations/Cipher.js +++ b/src/js/operations/Cipher.js @@ -385,6 +385,7 @@ var Cipher = { return encrypted.ciphertext.toString(Utils.format[args[2]]); }, + /** * Vigenère Encode operation. * @@ -474,6 +475,7 @@ var Cipher = { return output; }, + /** * @constant * @default @@ -484,6 +486,7 @@ var Cipher = { * @default */ AFFINE_B: 0, + /** * Affine Cipher Encode operation. * @@ -513,6 +516,7 @@ var Cipher = { return output; }, + /** * Affine Cipher Encode operation. * @@ -546,6 +550,7 @@ var Cipher = { return output; }, + /** * Atbash Cipher Encode operation. * @@ -558,6 +563,7 @@ var Cipher = { return Cipher.runAffineEnc(input, [25, 25]); }, + /** * @constant * @default