From 4f19129a69fb9fa433ee64686b90c5f083c78c78 Mon Sep 17 00:00:00 2001 From: Bharat Arya Date: Thu, 1 Oct 2020 13:18:18 +0530 Subject: [PATCH 1/5] Create AtBash.js --- Ciphers/AtBash.js | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 Ciphers/AtBash.js diff --git a/Ciphers/AtBash.js b/Ciphers/AtBash.js new file mode 100644 index 0000000000..b5bbdbed94 --- /dev/null +++ b/Ciphers/AtBash.js @@ -0,0 +1,29 @@ +function enAtbash(mensage) { + + var alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + var tebahpla = "ZYXWVUTSRQPONMLKJIHGFEDCBA"; + var alphabet1 = "abcdefghijklmnopqrstuvwxyz"; + var tebahpla1 = "zyxwvutsrqponmlkjihgfedcba"; + var decoded_string = ""; + + for (var i = 0; i < mensage.length; i++) { + var coded_letra = mensage.charAt(i); + + if (/[^a-zA-Z]/.test(mensage[i])) { + decoded_string = decoded_string+mensage[i]; + } + else if (mensage[i] === mensage[i].toUpperCase()) { + var letraPosMayus = alphabet.indexOf(coded_letra); + var tebLetraPosMayus = tebahpla.charAt(letraPosMayus); + decoded_string = decoded_string+tebLetraPosMayus; + } else { + var letraPosMinus1 = alphabet1.indexOf(coded_letra); + var tebLetraPosMinus1 = tebahpla1.charAt(letraPosMinus1); + decoded_string = decoded_string + tebLetraPosMinus1; + } + + } + return decoded_string; +} + +document.write(enAtbash("Hello World!")); From 23d1bfda28725a2c201348376260c265e8623a6f Mon Sep 17 00:00:00 2001 From: vinayak Date: Thu, 1 Oct 2020 23:54:44 +0530 Subject: [PATCH 2/5] Update AtBash.js --- Ciphers/AtBash.js | 47 ++++++++++++++++++++++------------------------- 1 file changed, 22 insertions(+), 25 deletions(-) diff --git a/Ciphers/AtBash.js b/Ciphers/AtBash.js index b5bbdbed94..d07700e59a 100644 --- a/Ciphers/AtBash.js +++ b/Ciphers/AtBash.js @@ -1,29 +1,26 @@ -function enAtbash(mensage) { - - var alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; - var tebahpla = "ZYXWVUTSRQPONMLKJIHGFEDCBA"; - var alphabet1 = "abcdefghijklmnopqrstuvwxyz"; - var tebahpla1 = "zyxwvutsrqponmlkjihgfedcba"; - var decoded_string = ""; - - for (var i = 0; i < mensage.length; i++) { - var coded_letra = mensage.charAt(i); - - if (/[^a-zA-Z]/.test(mensage[i])) { - decoded_string = decoded_string+mensage[i]; - } - else if (mensage[i] === mensage[i].toUpperCase()) { - var letraPosMayus = alphabet.indexOf(coded_letra); - var tebLetraPosMayus = tebahpla.charAt(letraPosMayus); - decoded_string = decoded_string+tebLetraPosMayus; - } else { - var letraPosMinus1 = alphabet1.indexOf(coded_letra); - var tebLetraPosMinus1 = tebahpla1.charAt(letraPosMinus1); - decoded_string = decoded_string + tebLetraPosMinus1; - } +const enAtbash = (message) => { + const alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' + const tebahpla = 'ZYXWVUTSRQPONMLKJIHGFEDCBA' + const alphabet1 = 'abcdefghijklmnopqrstuvwxyz' + const tebahpla1 = 'zyxwvutsrqponmlkjihgfedcba' + let decodedString = '' + for (let i = 0; i < message.length; i++) { + const codedLetra = message.charAt(i) + if (/[^a-zA-Z]/.test(message[i])) { + decodedString = decodedString + message[i] + } else if (message[i] === message[i].toUpperCase()) { + const letraPosMayus = alphabet.indexOf(codedLetra) + const tebLetraPosMayus = tebahpla.charAt(letraPosMayus) + decodedString = decodedString + tebLetraPosMayus + } else { + const letraPosMinus1 = alphabet1.indexOf(codedLetra) + const tebLetraPosMinus1 = tebahpla1.charAt(letraPosMinus1) + decodedString = decodedString + tebLetraPosMinus1 } - return decoded_string; + } + return decodedString } -document.write(enAtbash("Hello World!")); +// testing code +console.log(enAtbash('Hello World!')) From 4a8443dda88d735c7f67e363804b0d04284b96dc Mon Sep 17 00:00:00 2001 From: Bharat Arya Date: Sat, 3 Oct 2020 11:56:12 +0530 Subject: [PATCH 3/5] Update and rename AtBash.js to Atbash.js --- Ciphers/AtBash.js | 26 -------------------------- Ciphers/Atbash.js | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 26 deletions(-) delete mode 100644 Ciphers/AtBash.js create mode 100644 Ciphers/Atbash.js diff --git a/Ciphers/AtBash.js b/Ciphers/AtBash.js deleted file mode 100644 index d07700e59a..0000000000 --- a/Ciphers/AtBash.js +++ /dev/null @@ -1,26 +0,0 @@ -const enAtbash = (message) => { - const alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' - const tebahpla = 'ZYXWVUTSRQPONMLKJIHGFEDCBA' - const alphabet1 = 'abcdefghijklmnopqrstuvwxyz' - const tebahpla1 = 'zyxwvutsrqponmlkjihgfedcba' - let decodedString = '' - - for (let i = 0; i < message.length; i++) { - const codedLetra = message.charAt(i) - if (/[^a-zA-Z]/.test(message[i])) { - decodedString = decodedString + message[i] - } else if (message[i] === message[i].toUpperCase()) { - const letraPosMayus = alphabet.indexOf(codedLetra) - const tebLetraPosMayus = tebahpla.charAt(letraPosMayus) - decodedString = decodedString + tebLetraPosMayus - } else { - const letraPosMinus1 = alphabet1.indexOf(codedLetra) - const tebLetraPosMinus1 = tebahpla1.charAt(letraPosMinus1) - decodedString = decodedString + tebLetraPosMinus1 - } - } - return decodedString -} - -// testing code -console.log(enAtbash('Hello World!')) diff --git a/Ciphers/Atbash.js b/Ciphers/Atbash.js new file mode 100644 index 0000000000..4151904cb4 --- /dev/null +++ b/Ciphers/Atbash.js @@ -0,0 +1,34 @@ +/* +The Atbash cipher is a particular type of monoalphabetic cipher +formed by taking the alphabet and mapping it to its reverse, +so that the first letter becomes the last letter, +the second letter becomes the second to last letter, and so on. +*/ + + +/** + * Decrypt a Atbash cipher + * @param {String} str - string to be decrypted/encrypt + * @return {String} decrypted/encrypted string + */ + +const Atbash = (message) => { + let decodedString = '' + + for (let i = 0; i < message.length; i++) { + if (/[^a-zA-Z]/.test(message[i])) { + decodedString += message[i] + } else if (message[i] === message[i].toUpperCase()) { + decodedString += String.fromCharCode(90 + 65 - message.charCodeAt(i)) + } else { + decodedString += String.fromCharCode(122 + 97 - message.charCodeAt(i)) + } + } + return decodedString +} + +// Atbash Example +const encryptedString = 'HELLO WORLD' +const decryptedString = Atbash(encryptedString) + +console.log(decryptedString) // SVOOL DLIOW From 5023cdd7cc5d2195b9a0b9722d1fdd8405dd6bfd Mon Sep 17 00:00:00 2001 From: Bharat Arya Date: Sat, 3 Oct 2020 15:23:24 +0530 Subject: [PATCH 4/5] Update Atbash.js --- Ciphers/Atbash.js | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/Ciphers/Atbash.js b/Ciphers/Atbash.js index 4151904cb4..92b68e34ff 100644 --- a/Ciphers/Atbash.js +++ b/Ciphers/Atbash.js @@ -5,30 +5,25 @@ so that the first letter becomes the last letter, the second letter becomes the second to last letter, and so on. */ - /** * Decrypt a Atbash cipher * @param {String} str - string to be decrypted/encrypt * @return {String} decrypted/encrypted string */ - -const Atbash = (message) => { - let decodedString = '' - - for (let i = 0; i < message.length; i++) { - if (/[^a-zA-Z]/.test(message[i])) { - decodedString += message[i] - } else if (message[i] === message[i].toUpperCase()) { - decodedString += String.fromCharCode(90 + 65 - message.charCodeAt(i)) - } else { - decodedString += String.fromCharCode(122 + 97 - message.charCodeAt(i)) - } - } - return decodedString +function Atbash(message) { + let decodedString = '' + for(let i = 0; i < message.length; i++) { + if(/[^a-zA-Z]/.test(message[i])) { + decodedString += message[i] + } else if(message[i] === message[i].toUpperCase()) { + decodedString += String.fromCharCode(90 + 65 - message.charCodeAt(i)) + } else { + decodedString += String.fromCharCode(122 + 97 - message.charCodeAt(i)) + } + } + return decodedString } - // Atbash Example const encryptedString = 'HELLO WORLD' const decryptedString = Atbash(encryptedString) - console.log(decryptedString) // SVOOL DLIOW From 985e193ab794d24d87a890f26afb2c0346b51467 Mon Sep 17 00:00:00 2001 From: Bharat Arya Date: Sat, 3 Oct 2020 15:36:23 +0530 Subject: [PATCH 5/5] Update Atbash.js --- Ciphers/Atbash.js | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/Ciphers/Atbash.js b/Ciphers/Atbash.js index 92b68e34ff..5f43737497 100644 --- a/Ciphers/Atbash.js +++ b/Ciphers/Atbash.js @@ -1,8 +1,8 @@ /* -The Atbash cipher is a particular type of monoalphabetic cipher -formed by taking the alphabet and mapping it to its reverse, -so that the first letter becomes the last letter, -the second letter becomes the second to last letter, and so on. +The Atbash cipher is a particular type of monoalphabetic cipher +formed by taking the alphabet and mapping it to its reverse, +so that the first letter becomes the last letter, +the second letter becomes the second to last letter, and so on. */ /** @@ -10,18 +10,18 @@ the second letter becomes the second to last letter, and so on. * @param {String} str - string to be decrypted/encrypt * @return {String} decrypted/encrypted string */ -function Atbash(message) { - let decodedString = '' - for(let i = 0; i < message.length; i++) { - if(/[^a-zA-Z]/.test(message[i])) { - decodedString += message[i] - } else if(message[i] === message[i].toUpperCase()) { - decodedString += String.fromCharCode(90 + 65 - message.charCodeAt(i)) - } else { - decodedString += String.fromCharCode(122 + 97 - message.charCodeAt(i)) - } - } - return decodedString +function Atbash (message) { + let decodedString = '' + for (let i = 0; i < message.length; i++) { + if (/[^a-zA-Z]/.test(message[i])) { + decodedString += message[i] + } else if (message[i] === message[i].toUpperCase()) { + decodedString += String.fromCharCode(90 + 65 - message.charCodeAt(i)) + } else { + decodedString += String.fromCharCode(122 + 97 - message.charCodeAt(i)) + } + } + return decodedString } // Atbash Example const encryptedString = 'HELLO WORLD' pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy