Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit aa64514

Browse files
committed
Added Caesar Cipher to readme.md
1 parent b56915f commit aa64514

File tree

4 files changed

+8
-11
lines changed

4 files changed

+8
-11
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,8 @@ a set of rules that precisely define a sequence of operations.
134134
* `A` [Strongly Connected Components](src/algorithms/graph/strongly-connected-components) - Kosaraju's algorithm
135135
* `A` [Travelling Salesman Problem](src/algorithms/graph/travelling-salesman) - shortest possible route that visits each city and returns to the origin city
136136
* **Cryptography**
137-
* `B` [Polynomial Hash](src/algorithms/cryptography/polynomial-hash) - rolling hash function based on polynomial
137+
* `B` [Polynomial Hash](src/algorithms/cryptography/polynomial-hash) - rolling hash function
138+
* `B` [Caesar Cipher](src/algorithms/cryptography/caesar-cipher) - caesar-cipher
138139
* **Uncategorized**
139140
* `B` [Tower of Hanoi](src/algorithms/uncategorized/hanoi-tower)
140141
* `B` [Square Matrix Rotation](src/algorithms/uncategorized/square-matrix-rotation) - in-place algorithm

src/algorithms/cryptography/caesar-cipher/CaesarCipher.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export default class CaesarCipher {
1414
}
1515

1616
let output = '';
17-
for (let i = 0; i < word.length; i + 1) {
17+
for (let i = 0; i < word.length; i += 1) {
1818
let c = word[i];
1919
if (c.match(/[a-z]/i)) {
2020
const code = word.charCodeAt(i);

src/algorithms/cryptography/caesar-cipher/README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,5 @@ Where x is the text to be encrypted/decrypted and k is the private key or the am
1111

1212
## References
1313

14-
- [Where to Use Polynomial String Hashing](https://www.mii.lt/olympiads_in_informatics/pdf/INFOL119.pdf)
15-
- [Hashing on uTexas](https://www.cs.utexas.edu/~mitra/csSpring2017/cs313/lectures/hash.html)
16-
- [Hash Function on Wikipedia](https://en.wikipedia.org/wiki/Hash_function)
17-
- [Rolling Hash on Wikipedia](https://en.wikipedia.org/wiki/Rolling_hash)
14+
- [Ceasar Cipher](http://practicalcryptography.com/ciphers/caesar-cipher/)
15+
Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
import CaesarCipher from '../CaesarCipher';
22

33
describe('ceasarCipher', () => {
4-
it('shifts the character by a particular amount as specified by the user', () => {
4+
it('ciphers and decyphers the text', () => {
55
const cipher = new CaesarCipher();
6-
const encText = cipher.encrypt('ABC', 3);
7-
const decText = cipher.decrypt('DEF', 3);
86

9-
expect(encText).toEqual('XYZ');
10-
expect(decText).toEqual('ABC');
7+
expect(cipher.encrypt('ABC', 3)).toBe('DEF');
8+
expect(cipher.decrypt('DEF', 3)).toBe('ABC');
119
});
1210
});

0 commit comments

Comments
 (0)