File tree Expand file tree Collapse file tree 4 files changed +8
-11
lines changed
src/algorithms/cryptography/caesar-cipher Expand file tree Collapse file tree 4 files changed +8
-11
lines changed Original file line number Diff line number Diff line change @@ -134,7 +134,8 @@ a set of rules that precisely define a sequence of operations.
134
134
* ` A ` [ Strongly Connected Components] ( src/algorithms/graph/strongly-connected-components ) - Kosaraju's algorithm
135
135
* ` A ` [ Travelling Salesman Problem] ( src/algorithms/graph/travelling-salesman ) - shortest possible route that visits each city and returns to the origin city
136
136
* ** 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
138
139
* ** Uncategorized**
139
140
* ` B ` [ Tower of Hanoi] ( src/algorithms/uncategorized/hanoi-tower )
140
141
* ` B ` [ Square Matrix Rotation] ( src/algorithms/uncategorized/square-matrix-rotation ) - in-place algorithm
Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ export default class CaesarCipher {
14
14
}
15
15
16
16
let output = '' ;
17
- for ( let i = 0 ; i < word . length ; i + 1 ) {
17
+ for ( let i = 0 ; i < word . length ; i += 1 ) {
18
18
let c = word [ i ] ;
19
19
if ( c . match ( / [ a - z ] / i) ) {
20
20
const code = word . charCodeAt ( i ) ;
Original file line number Diff line number Diff line change @@ -11,7 +11,5 @@ Where x is the text to be encrypted/decrypted and k is the private key or the am
11
11
12
12
## References
13
13
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
+
Original file line number Diff line number Diff line change 1
1
import CaesarCipher from '../CaesarCipher' ;
2
2
3
3
describe ( 'ceasarCipher' , ( ) => {
4
- it ( 'shifts the character by a particular amount as specified by the user ' , ( ) => {
4
+ it ( 'ciphers and decyphers the text ' , ( ) => {
5
5
const cipher = new CaesarCipher ( ) ;
6
- const encText = cipher . encrypt ( 'ABC' , 3 ) ;
7
- const decText = cipher . decrypt ( 'DEF' , 3 ) ;
8
6
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' ) ;
11
9
} ) ;
12
10
} ) ;
You can’t perform that action at this time.
0 commit comments