-
-
Notifications
You must be signed in to change notification settings - Fork 46.6k
Revamp md5.py
#8065
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
Merged
Merged
Revamp md5.py
#8065
Changes from 2 commits
Commits
Show all changes
46 commits
Select commit
Hold shift + click to select a range
7fcce6e
Add type hints to md5.py
tianyizheng02 a20ccf8
Rename some vars to snake case
tianyizheng02 ce2d51f
Specify functions imported from math
tianyizheng02 d243bf3
Rename vars and functions to be more descriptive
tianyizheng02 b29ab66
Make tests from test function into doctests
tianyizheng02 0b5e6a4
Clarify more var names
tianyizheng02 18d891c
Refactor some MD5 code into preprocess function
tianyizheng02 27a8b29
Simplify loop indices in get_block_words
tianyizheng02 885f116
Add more detailed comments, docs, and doctests
tianyizheng02 20085e2
Merge branch 'TheAlgorithms:master' into md5
tianyizheng02 f7ba9da
updating DIRECTORY.md
d289ade
updating DIRECTORY.md
8b44f10
Merge branch 'TheAlgorithms:master' into master
tianyizheng02 200fc0d
Merge branch 'TheAlgorithms:master' into master
tianyizheng02 0d64972
Merge branch 'TheAlgorithms:master' into md5
tianyizheng02 3332400
Merge branch 'TheAlgorithms:master' into md5
tianyizheng02 2aea9a2
updating DIRECTORY.md
3ff65ba
Merge branch 'TheAlgorithms:master' into master
tianyizheng02 9d1971b
updating DIRECTORY.md
f2e8fbd
Merge branch 'TheAlgorithms:master' into master
tianyizheng02 5f404b4
updating DIRECTORY.md
1b93899
Merge branch 'TheAlgorithms:master' into master
tianyizheng02 e133a3b
Merge branch 'TheAlgorithms:master' into md5
tianyizheng02 30ee318
Merge branch 'TheAlgorithms:master' into master
tianyizheng02 27f57c2
Merge branch 'TheAlgorithms:master' into md5
tianyizheng02 3fbe643
Add type hints to md5.py
tianyizheng02 adfe215
Rename some vars to snake case
tianyizheng02 17fc171
Specify functions imported from math
tianyizheng02 2400676
Rename vars and functions to be more descriptive
tianyizheng02 cd501ba
Make tests from test function into doctests
tianyizheng02 feefe88
Clarify more var names
tianyizheng02 2b7a465
Refactor some MD5 code into preprocess function
tianyizheng02 84f7ac3
Simplify loop indices in get_block_words
tianyizheng02 5fadb6e
Add more detailed comments, docs, and doctests
tianyizheng02 83bcabc
Merge branch 'md5' of github.com:tianyizheng02/Python into md5
tianyizheng02 24457b9
updating DIRECTORY.md
e73d826
Merge branch 'md5' of github.com:tianyizheng02/Python into md5
tianyizheng02 61d7761
updating DIRECTORY.md
4959857
Merge branch 'TheAlgorithms:master' into md5
tianyizheng02 c69bda1
Merge branch 'TheAlgorithms:master' into md5
tianyizheng02 aa1a18f
updating DIRECTORY.md
4bec95e
Merge branch 'TheAlgorithms:master' into md5
tianyizheng02 c71f64a
updating DIRECTORY.md
17c76ba
Convert str types to bytes
tianyizheng02 c775f15
Add tests comparing md5_me to hashlib's md5
tianyizheng02 1f3842e
Replace line-break backslashes with parentheses
tianyizheng02 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use https://docs.python.org/3/library/struct.html to do the endian conversations or at least use
struct
in the doctests forto_little_endian()
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Admittedly I'm not that familiar with the
struct
module, but I'm not sure how to make it work with theto_little_endian()
function.To me, the problem is that the original function
rearrange()
doesn't actually convert strings to little-endian. Instead, it treats 32-char string inputs as if they were 32-bit bit strings, with each char as a single "bit". It then restructures the input in an "little-endian fashion": the 8 least significant "bits" come first, followed by the 8 next least significant "bits", etc. Thus it looks little-endian if you squint hard enough.Since the inputs to
rearrange()
/to_little_endian()
are being restructured in units far larger than a byte, I'm not sure if thestruct
module would work here, unless I'm misunderstanding how the module works.