Repository navigation
Add an optional uppercase digest to the Hash Generator - #21
Open
SakarPaisen wants to merge 1 commit into
Open
SakarPaisen wants to merge 1 commit into
SakarPaisen wants to merge 1 commit into
Conversation
hash_text takes uppercase: bool = False. The digest is computed once and only the hexadecimal string is reformatted, so the algorithm name, the default lowercase output and error handling are unchanged. Tests cover the default, the documented abc example, all three algorithms and empty text; the guide and docstring document the option.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What
Closes #3.
hash_texttakes an optionaluppercase: bool = False. The digest is computed once; only the hexadecimal string is reformatted, so the algorithm name, the default lowercase output and the error handling are unchanged.Scope
src/mcp_tools_lab/tools/hashing.py— the new optional parameter and docstring.tests/test_hashing.py— four new tests (default unchanged, documented example, all three algorithms, empty text).docs/tool-guide.md— the signature and one example.server.pyregistershash_textdirectly, so the typed parameter is exposed to MCP clients without another wrapper.Tests added
test_uppercase_digest:hash_text("abc", uppercase=True)equals the uppercase of the known SHA-256 vector, andalgorithmstayssha256.test_uppercase_is_optional_and_algorithm_is_unchanged: the default still starts withba7816bf, anduppercase=Falseequals the plain call.test_uppercase_supports_every_algorithm:sha256,sha512,blake2b— uppercase equals the lowercased digest uppercased, same length, algorithm unchanged.test_uppercase_empty_text: empty input hashes toE3B0C442…B855in uppercase.Checks
python -m pytest tests/test_hashing.py -q— 11 passedpython -m pytest -q— 68 passedpython .github/scripts/check_rules.py—Scanned 11 files under src/ for print() and network imports: OKPython: 3.13 on Windows 11.
(Full disclosure: I used an AI coding assistant for this change, and I reviewed and verified everything submitted here.)