Skip to content

Commit

Permalink
Removes Atbash
Browse files Browse the repository at this point in the history
  • Loading branch information
ffraenz committed Apr 19, 2019
1 parent 4337816 commit 389eb46
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 120 deletions.
1 change: 0 additions & 1 deletion README.md
Expand Up @@ -37,7 +37,6 @@ Encoders manipulate content by encoding or decoding it in a specific way and usi
| `alphabetical-substitution` | Substitution cipher | [Alphabetical substitution](https://en.wikipedia.org/wiki/Substitution_cipher#Simple_substitution) |
| `affine-cipher` | Substitution cipher | [Affine Cipher](https://en.wikipedia.org/wiki/Affine_cipher) |
| `caesar-cipher` | Substitution cipher | [Caesar cipher](https://en.wikipedia.org/wiki/Caesar_cipher) |
| `atbash` | Substitution cipher | [Atbash](https://en.wikipedia.org/wiki/Atbash) using latin or hebrew alphabet |
| `vigenere-cipher` | Substitution cipher | [Vigenère cipher](https://en.wikipedia.org/wiki/Vigen%C3%A8re_cipher) incl. [Beaufort cipher](https://en.wikipedia.org/wiki/Beaufort_cipher) variants |
| `enigma` | Substitution cipher | [Enigma machine](https://en.wikipedia.org/wiki/Enigma_machine) incl. 13 models |
| `base64` | Encoding | [Base64](https://en.wikipedia.org/wiki/Base64) incl. variants base64url, … |
Expand Down
89 changes: 0 additions & 89 deletions src/Encoder/Atbash.js

This file was deleted.

2 changes: 0 additions & 2 deletions src/Factory/Brick.js
Expand Up @@ -5,7 +5,6 @@ import Factory from '../Factory'
import AffineCipherEncoder from '../Encoder/AffineCipher'
import AlphabeticalSubstitutionEncoder from '../Encoder/AlphabeticalSubstitution'
import Ascii85Encoder from '../Encoder/Ascii85'
import AtbashEncoder from '../Encoder/Atbash'
import Base64Encoder from '../Encoder/Base64'
import BitwiseOperationEncoder from '../Encoder/BitwiseOperation'
import BlockCipherEncoder from '../Encoder/BlockCipher'
Expand Down Expand Up @@ -53,7 +52,6 @@ export default class BrickFactory extends Factory {
ROT13Encoder,
AffineCipherEncoder,
CaesarCipherEncoder,
AtbashEncoder,
VigenereCipherEncoder,
EnigmaEncoder,
Base64Encoder,
Expand Down
14 changes: 11 additions & 3 deletions test/Encoder/AlphabeticalSubstitution.js
Expand Up @@ -7,24 +7,32 @@ import AlphabeticalSubstitutionEncoder from '../../src/Encoder/AlphabeticalSubst
/** @test {AlphabeticalSubstitutionEncoder} */
describe('AlphabeticalSubstitutionEncoder', () => EncoderTester.test(AlphabeticalSubstitutionEncoder, [
{
// Atbash example
// Atbash latin
settings: {
plaintextAlphabet: 'abcdefghijklmnopqrstuvwxyz',
ciphertextAlphabet: 'zyxwvutsrqponmlkjihgfedcba',
caseSensitivity: false,
includeForeignChars: true
},
content: 'the quick brown fox jumps over 13 lazy dogs.',
expectedResult: 'gsv jfrxp yildm ulc qfnkh levi 13 ozab wlth.'
},
{
// Atbash hebrew
settings: {
plaintextAlphabet: 'אבגדהוזחטיכלמנסעפצקרשת',
ciphertextAlphabet: 'תשרקצפעסנמלכיטחזוהדגבא',
includeForeignChars: true
},
content: 'אבגדהוזחטיכלמנסעפצקרשת',
expectedResult: 'תשרקצפעסנמלכיטחזוהדגבא'
},
{
// Wikipedia example
settings: {
plaintextAlphabet: 'abcdefghijklmnopqrstuvwxyz',
ciphertextAlphabet: 'zebras',
// Ciphertext alphabet 'zebras' should be interpreted
// as 'zebrascdfghijklmnopqtuvwxy'
caseSensitivity: false,
includeForeignChars: true
},
content: 'flee at once. we are discovered!',
Expand Down
19 changes: 0 additions & 19 deletions test/Encoder/Atbash.js

This file was deleted.

18 changes: 12 additions & 6 deletions test/Pipe.js
Expand Up @@ -3,7 +3,7 @@ import assert from 'assert'
import { describe, it } from 'mocha'

import AffineCipherEncoder from '../src/Encoder/AffineCipher'
import AtbashEncoder from '../src/Encoder/Atbash'
import AlphabeticalSubstitutionEncoder from '../src/Encoder/AlphabeticalSubstitution'
import BrickFactory from '../src/Factory/Brick'
import Pipe from '../src/Pipe'
import ROT13Encoder from '../src/Encoder/ROT13'
Expand All @@ -20,6 +20,12 @@ const examplePipeData = {
contentBucket: 0
}

const atbashBrick = {
name: 'alphabetical-substitution',
plaintextAlphabet: 'abcdefghijklmnopqrstuvwxyz',
ciphertextAlphabet: 'zyxwvutsrqponmlkjihgfedcba'
}

/** @test {Pipe} */
describe('Pipe', () => {
/** @test {Pipe.extract} */
Expand Down Expand Up @@ -163,8 +169,8 @@ describe('Pipe', () => {
const a = await pipe.getContent(2)
assert.strictEqual(a.getString(), 'xrw ceyim bjosh doz feavq olwj 13 tung pokq')
// Replace second encoder, the last bucket should update
pipe.spliceBricks(2, 1, [{ name: 'atbash' }])
assert.strictEqual(pipe.getBricks()[2] instanceof AtbashEncoder, true)
pipe.spliceBricks(2, 1, [atbashBrick])
assert.strictEqual(pipe.getBricks()[2] instanceof AlphabeticalSubstitutionEncoder, true)
const b = await pipe.getContent(2)
assert.strictEqual(b.getString(), 'pvq kioea ldyuf jyn himrw ybqd 13 tszg xycw')
// Change translation direction by changing the last bucket
Expand Down Expand Up @@ -196,7 +202,7 @@ describe('Pipe', () => {
const b = await pipe.getContent(2)
assert.strictEqual(b.getString(), 'uryyb jbeyq')
// Replace both encoders, only the last bucket should update
pipe.spliceBricks(1, 3, [{ name: 'rot13' }, { name: 'text' }, { name: 'atbash' }])
pipe.spliceBricks(1, 3, [{ name: 'rot13' }, { name: 'text' }, atbashBrick])
const c = await pipe.getContent(0)
assert.strictEqual(c.getString(), 'ahiib rbuis')
const d = await pipe.getContent(2)
Expand All @@ -207,7 +213,7 @@ describe('Pipe', () => {
const pipe = Pipe.extract({
bricks: [
{ name: 'text' },
{ name: 'atbash' },
atbashBrick,
{ name: 'text' },
{ name: 'rot13' },
{ name: 'text' }
Expand Down Expand Up @@ -244,7 +250,7 @@ describe('Pipe', () => {
const a = await pipe.getContent(0)
assert.strictEqual(a.getString(), 'hello world')
// Replace first two encoders by a single new one
pipe.spliceBricks(1, 3, [{ name: 'atbash' }])
pipe.spliceBricks(1, 3, [atbashBrick])
const b = await pipe.getContent(2)
assert.strictEqual(b.getString(), 'jvjah ewtcb')
const c = await pipe.getContent(0)
Expand Down

0 comments on commit 389eb46

Please sign in to comment.