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

Update Decryption class so that it matches specification #19

Closed
wants to merge 1 commit into from
Closed

Update Decryption class so that it matches specification #19

wants to merge 1 commit into from

Conversation

ghost
Copy link

@ghost ghost commented May 9, 2018

Python 3.6.5 (default, Apr 14 2018, 13:17:30) 
[GCC 7.3.1 20180406] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from lantern.modules import shift
>>> from lantern import fitness
>>> ciphertext = "iodj{EuxwhIrufhLvEhvwIrufh}"
>>> decryptions = shift.crack(ciphertext, fitness.english.quadgrams)
>>> print(decryptions[0])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: __str__ returned non-string (type list)

I think it makes sense to have the plaintext stored as a list. If it's to be kept as a list, the __str__ method should be updated to join the list prior to returning the plaintext. The documentation would need to be updated accordingly as well. For now, I've updated the Decryption class so that self.plaintext is a string as it meets the spec.

@coveralls
Copy link

coveralls commented May 9, 2018

Coverage Status

Coverage remained the same at 99.569% when pulling e512319 on jtalowell:master into 235e163 on CameronLonsdale:master.

@ghost
Copy link
Author

ghost commented May 9, 2018

This is on the current master branch.

Python 3.6.5 (default, Apr 14 2018, 13:17:30) 
[GCC 7.3.1 20180406] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from lantern.modules import shift
>>> from lantern import fitness
>>> ciphertext = "iodj{EuxwhIrufhLvEhvwIrufh}"
>>> decryptions = shift.crack(ciphertext, fitness.english.quadgrams)
>>> print(decryptions[0])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: __str__ returned non-string (type list)
>>> from lantern.modules import simplesubstitution
>>> ciphertext = "iodj{EuxwhIrufhLvEhvwIrufh}"
>>> decryptions = simplesubstitution.crack(ciphertext, fitness.english.quadgrams)
>>> print(decryptions[0])
oldi{NtureOftheSaNearOfthe}

The inconsistency here probably needs a better fix than just joining the string (this pull request). The Decryption class should either accept a string or a list and the other modules should be changed accordingly.

@CameronLonsdale CameronLonsdale self-requested a review May 18, 2018 06:15
@CameronLonsdale
Copy link
Owner

Thanks for this PR, but for now the str representation will be removed in favor of manually joining decryptions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants