Skip to content

fix: handle Unicode in Adler-32 checksum - #15692

Open
SwetaKumari7 wants to merge 1 commit into
TheAlgorithms:masterfrom
SwetaKumari7:fix-adler32-unicode-upstream
Open

SwetaKumari7 wants to merge 1 commit into
TheAlgorithms:masterfrom
SwetaKumari7:fix-adler32-unicode-upstream

Conversation

@SwetaKumari7

Copy link
Copy Markdown
Contributor

Summary

Fixes Unicode handling in the Adler-32 checksum implementation.

Changes

  • Encode input strings as UTF-8 before processing.
  • Iterate over bytes instead of Unicode characters.
  • Preserve the existing function signature and return type.
  • Add doctests for Unicode strings and empty input.
  • Preserve existing ASCII test cases.

Testing

  • python -m doctest hashes/adler32.py
  • ruff check hashes/adler32.py
  • ruff format --check hashes/adler32.py
  • git diff --check

Also verified Unicode checksum results against Python's zlib.adler32().

Fixes #15635

This branch has not been deployed

No deployments
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.

hashes/adler32.py: checksum diverges from the Adler-32 spec for any non-ASCII input (sums Unicode code points instead of bytes)

1 participant