Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 1db7aa7

Browse files
authoredOct 25, 2020
Merge pull request #1 from TheAlgorithms/master
Updating the Forked Repository
2 parents 9e6fe4b + 6c2f83b commit 1db7aa7

File tree

94 files changed

+1883
-197
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

94 files changed

+1883
-197
lines changed
 

‎.prettierrc

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"arrowParens": "always",
3+
"bracketSpacing": true,
4+
"endOfLine": "lf",
5+
"insertPragma": false,
6+
"printWidth": 80,
7+
"proseWrap": "preserve",
8+
"quoteProps": "as-needed",
9+
"requirePragma": false,
10+
"semi": false,
11+
"singleQuote": true,
12+
"tabWidth": 2,
13+
"trailingComma": "none",
14+
"useTabs": false
15+
}

‎Ciphers/ROT13.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/**
2+
* Transcipher a ROT13 cipher
3+
* @param {String} text - string to be encrypted
4+
* @return {String} - decrypted string
5+
*/
6+
const transcipher = (text) => {
7+
const originalCharacterList = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
8+
const toBeMappedCharaterList = 'NOPQRSTUVWXYZABCDEFGHIJKLMnopqrstuvwxyzabcdefghijklm'
9+
const index = x => originalCharacterList.indexOf(x)
10+
const replace = x => index(x) > -1 ? toBeMappedCharaterList[index(x)] : x
11+
return text.split('').map(replace).join('')
12+
}
13+
14+
(() => {
15+
const messageToBeEncrypted = 'The quick brown fox jumps over the lazy dog'
16+
console.log(`Original Text = "${messageToBeEncrypted}"`)
17+
const rot13CipheredText = transcipher(messageToBeEncrypted)
18+
console.log(`Ciphered Text = "${rot13CipheredText}"`)
19+
const rot13DecipheredText = transcipher(rot13CipheredText)
20+
console.log(`Deciphered Text = "${rot13DecipheredText}"`)
21+
})()

0 commit comments

Comments
 (0)
Please sign in to comment.