Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync simple-cipher to version 2.0.0 #246

Merged
merged 1 commit into from
Apr 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions exercises/simple-cipher/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ for A, and so with the others."

Ciphers are very straight-forward algorithms that allow us to render
text less readable while still allowing easy deciphering. They are
vulnerable to many forms of cryptoanalysis, but we are lucky that
generally our little sisters are not cryptoanalysts.
vulnerable to many forms of cryptanalysis, but we are lucky that
generally our little sisters are not cryptanalysts.

The Caesar Cipher was used for some messages from Julius Caesar that
were sent afield. Now Caesar knew that the cipher wasn't very good, but
Expand Down Expand Up @@ -61,10 +61,7 @@ substitution cipher a little more fault tolerant by providing a source
of randomness and ensuring that the key contains only lowercase letters.

If someone doesn't submit a key at all, generate a truly random key of
at least 100 characters in length.

If the key submitted is not composed only of lowercase letters, your
solution should handle the error in a language-appropriate way.
at least 100 alphanumeric characters in length.

## Extensions

Expand All @@ -83,10 +80,10 @@ on Wikipedia][dh] for one of the first implementations of this scheme.

## Setup

Go through the setup instructions for TypeScript to
install the necessary dependencies:
Go through the setup instructions for TypeScript to install the necessary
dependencies:

http://exercism.io/languages/typescript
[https://exercism.io/tracks/typescript/installation](https://exercism.io/tracks/typescript/installation)

## Requirements

Expand All @@ -104,11 +101,16 @@ Execute the tests with:
$ yarn test
```

In the test suites all tests but the first have been skipped.

Once you get a test passing, you can enable the next one by changing `xit` to
`it`.

## Source

Substitution Cipher at Wikipedia [http://en.wikipedia.org/wiki/Substitution_cipher](http://en.wikipedia.org/wiki/Substitution_cipher)

## Submitting Incomplete Solutions
It's possible to submit an incomplete solution so you can see how others have completed the exercise.

It's possible to submit an incomplete solution so you can see how others have
completed the exercise.
30 changes: 2 additions & 28 deletions exercises/simple-cipher/simple-cipher.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,32 +38,6 @@ describe('Random key cipher', () => {
})
})

describe('Incorrect key cipher', () => {
xit('throws an error with an all caps key', () => {
expect(() => {
new SimpleCipher('ABCDEF')
}).toThrowError('Bad key')
})

xit('throws an error with a mixed case key', () => {
expect(() => {
new SimpleCipher('AbcdEF')
}).toThrowError('Bad key')
})

xit('throws an error with a numeric key', () => {
expect(() => {
new SimpleCipher('12345')
}).toThrow('Bad key')
})

xit('throws an error with an empty key', () => {
expect(() => {
new SimpleCipher('')
}).toThrow('Bad key')
})
})

describe('Substitution cipher', () => {
const key = 'abcdefghij'
const simpleCipher = new SimpleCipher(key)
Expand Down Expand Up @@ -97,12 +71,12 @@ describe('Substitution cipher', () => {
expect(simpleCipher.decode('zabcdefghi')).toEqual('zzzzzzzzzz')
})

xit('can handle messages longer than the key (encode)', () => {
xit('can encode messages longer than the key"', () => {
expect(new SimpleCipher('abc').encode('iamapandabear'))
.toEqual('iboaqcnecbfcr')
})

xit('can handle messages longer than the key (decode)', () => {
xit('can decode messages longer than the key', () => {
expect(new SimpleCipher('abc').decode('iboaqcnecbfcr'))
.toEqual('iamapandabear')
})
Expand Down