Conversation
| """ | ||
|
|
||
| from collections.abc import Generator | ||
| from math import sin |
There was a problem hiding this comment.
Please use https://docs.python.org/3/library/struct.html to do the endian conversations or at least use struct in the doctests for to_little_endian().
There was a problem hiding this comment.
Admittedly I'm not that familiar with the struct module, but I'm not sure how to make it work with the to_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 the struct module would work here, unless I'm misunderstanding how the module works.
|
The ruff errors should go away if you rebase. |
|
For me, there are two things that I see missing...
|
* Add type hints to md5.py
* Rename some vars to snake case
* Specify functions imported from math
* Rename vars and functions to be more descriptive
* Make tests from test function into doctests
* Clarify more var names
* Refactor some MD5 code into preprocess function
* Simplify loop indices in get_block_words
* Add more detailed comments, docs, and doctests
* updating DIRECTORY.md
* updating DIRECTORY.md
* updating DIRECTORY.md
* updating DIRECTORY.md
* updating DIRECTORY.md
* Add type hints to md5.py
* Rename some vars to snake case
* Specify functions imported from math
* Rename vars and functions to be more descriptive
* Make tests from test function into doctests
* Clarify more var names
* Refactor some MD5 code into preprocess function
* Simplify loop indices in get_block_words
* Add more detailed comments, docs, and doctests
* updating DIRECTORY.md
* updating DIRECTORY.md
* updating DIRECTORY.md
* updating DIRECTORY.md
* Convert str types to bytes
* Add tests comparing md5_me to hashlib's md5
* Replace line-break backslashes with parentheses
---------
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Describe your change:
Revamped
hashes/md5.py:There's a lot in this PR, so let me know if anything else should be changed or if any existing changes should be reverted
Checklist:
Fixes: #{$ISSUE_NO}.