asweigart / codebreaker Goto Github PK
View Code? Open in Web Editor NEW"Hacking Secret Ciphers with Python" programs
Home Page: http://inventwithpython.com/blog/become-a-code-breaker-with-python/
"Hacking Secret Ciphers with Python" programs
Home Page: http://inventwithpython.com/blog/become-a-code-breaker-with-python/
petey$ python VigenereHacker.py
Kasiski Examination results say the most likely key lengths are:
Traceback (most recent call last):
File "VigenereHacker.py", line 259, in <module>
main()
File "VigenereHacker.py", line 18, in main
hackedMessage = hackVigenere(ciphertext)
File "VigenereHacker.py", line 242, in hackVigenere
if hackedMessage == None:
UnboundLocalError: local variable 'hackedMessage' referenced before assignment
Not obvious to me how to fix, if I figure it out will submit a pull request.
I think the problematic code is:
# The number of "columns" in our transposition grid:
numOfColumns = math.ceil(len(message) / key)
Which causes:
Traceback (most recent call last):
File "/Users/alexjs/dev/codebreaker/transpositionDecrypt.py", line 55, in <module>
main()
File "/Users/alexjs/dev/codebreaker/transpositionDecrypt.py", line 10, in main
plaintext = decryptMessage(myKey, myMessage)
File "/Users/alexjs/dev/codebreaker/transpositionDecrypt.py", line 32, in decryptMessage
plaintext = [''] * numOfColumns
Wrapping it as int(math.ceil(len(message) / key))
allows the script to run, but decryption fails, so I'm assuming that's not the actual fix.
Python 2.7.2, OS X
I want to use Sourcegraph for codebreaker code search, browsing, and usage examples. Can an admin enable Sourcegraph for this repository? Just go to https://sourcegraph.com/github.com/asweigart/codebreaker. (It should only take 30 seconds.)
Thank you!
If transpositionCipherFile.py is run (instead of imported as a module)
Should be:
If transpositionFileCipher.py is run (instead of imported as a module)
# value in name) with the the n,e and d,e integers written in them,
Should be:
# value in name) with the n,e and d,e integers written in them,
# handle the wrap-around if num is 26 or larger or less than 0
Should be:
# handle the wrap-around if num is less than 0
When decrypting, the number to wrap-around can only be less than 0 since it is always doing a subtraction to decrypt.
# If a letter is solved, than it cannot possibly be a potential
Should be:
# If a letter is solved, then it cannot possibly be a potential
line 64 in makeRsaKeys.py should be
print('The private key is a %s and a %s digit number.' % (len(str(privateKey[0])), len(str(privateKey[1]))))
instead of:
print('The private key is a %s and a %s digit number.' % (len(str(publicKey[0])), len(str(publicKey[1]))))
I want to use Sourcegraph for codebreaker code search, browsing, and usage examples. Can an admin enable Sourcegraph for this repository? Just go to https://sourcegraph.com/github.com/asweigart/codebreaker. (It should only take 30 seconds.)
Thank you!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.