forked from trekhleb/javascript-algorithms
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
254 additions
and
202 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 26 additions & 9 deletions
35
...e-cipher/__test__/railFenceCypher.test.js → ...e-cipher/__test__/railFenceCipher.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,43 @@ | ||
import encodeRailFenceCipher from '../encodeRailFence'; | ||
import decodeRailFenceCipher from '../decodeRailFence'; | ||
import { encodeRailFenceCipher, decodeRailFenceCipher } from '../railFenceCipher'; | ||
|
||
describe('rail fence cipher', () => { | ||
describe('railFenceCipher', () => { | ||
it('encodes a string correctly for base=3', () => { | ||
expect(encodeRailFenceCipher('', 3)).toBe(''); | ||
expect(encodeRailFenceCipher('WEAREDISCOVEREDFLEEATONCE', 3)).toBe('WECRLTEERDSOEEFEAOCAIVDEN'); | ||
expect(encodeRailFenceCipher('Hello, World!', 3)).toBe('Hoo!el,Wrdl l'); | ||
expect(encodeRailFenceCipher('12345', 3)).toBe( | ||
'15243', | ||
); | ||
expect(encodeRailFenceCipher('WEAREDISCOVEREDFLEEATONCE', 3)).toBe( | ||
'WECRLTEERDSOEEFEAOCAIVDEN', | ||
); | ||
expect(encodeRailFenceCipher('Hello, World!', 3)).toBe( | ||
'Hoo!el,Wrdl l', | ||
); | ||
}); | ||
|
||
it('decodes a string correctly for base=3', () => { | ||
expect(decodeRailFenceCipher('', 3)).toBe(''); | ||
expect(decodeRailFenceCipher('WECRLTEERDSOEEFEAOCAIVDEN', 3)).toBe('WEAREDISCOVEREDFLEEATONCE'); | ||
expect(decodeRailFenceCipher('Hoo!el,Wrdl l', 3)).toBe('Hello, World!'); | ||
expect(decodeRailFenceCipher('WECRLTEERDSOEEFEAOCAIVDEN', 3)).toBe( | ||
'WEAREDISCOVEREDFLEEATONCE', | ||
); | ||
expect(decodeRailFenceCipher('Hoo!el,Wrdl l', 3)).toBe( | ||
'Hello, World!', | ||
); | ||
expect(decodeRailFenceCipher('15243', 3)).toBe( | ||
'12345', | ||
); | ||
}); | ||
|
||
it('encodes a string correctly for base=4', () => { | ||
expect(encodeRailFenceCipher('', 4)).toBe(''); | ||
expect(encodeRailFenceCipher('THEYAREATTACKINGFROMTHENORTH', 4)).toBe('TEKOOHRACIRMNREATANFTETYTGHH'); | ||
expect(encodeRailFenceCipher('THEYAREATTACKINGFROMTHENORTH', 4)).toBe( | ||
'TEKOOHRACIRMNREATANFTETYTGHH', | ||
); | ||
}); | ||
|
||
it('decodes a string correctly for base=4', () => { | ||
expect(decodeRailFenceCipher('', 4)).toBe(''); | ||
expect(decodeRailFenceCipher('TEKOOHRACIRMNREATANFTETYTGHH', 4)).toBe('THEYAREATTACKINGFROMTHENORTH'); | ||
expect(decodeRailFenceCipher('TEKOOHRACIRMNREATANFTETYTGHH', 4)).toBe( | ||
'THEYAREATTACKINGFROMTHENORTH', | ||
); | ||
}); | ||
}); |
108 changes: 0 additions & 108 deletions
108
src/algorithms/cryptography/rail-fence-cipher/decodeRailFence.js
This file was deleted.
Oops, something went wrong.
52 changes: 0 additions & 52 deletions
52
src/algorithms/cryptography/rail-fence-cipher/encodeRailFence.js
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.