Skip to content

Add an optional uppercase digest to the Hash Generator - #21

Open
SakarPaisen wants to merge 1 commit into
github-community-gitam:mainfrom
SakarPaisen:feat/hash-uppercase-option-3
Open

SakarPaisen wants to merge 1 commit into
github-community-gitam:mainfrom
SakarPaisen:feat/hash-uppercase-option-3

Conversation

@SakarPaisen

Copy link
Copy Markdown
Contributor

What

Closes #3.

hash_text takes an optional uppercase: 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.

>>> hash_text("abc")["digest"][:8]
'ba7816bf'
>>> hash_text("abc", uppercase=True)["digest"][:8]
'BA7816BF'

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.py registers hash_text directly, 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, and algorithm stays sha256.
  • test_uppercase_is_optional_and_algorithm_is_unchanged: the default still starts with ba7816bf, and uppercase=False equals 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 to E3B0C442…B855 in uppercase.

Checks

  • python -m pytest tests/test_hashing.py -q — 11 passed
  • python -m pytest -q — 68 passed
  • python .github/scripts/check_rules.py — Scanned 11 files under src/ for print() and network imports: OK
  • Direct call check printing both results to confirm the exact digests

Python: 3.13 on Windows 11.

(Full disclosure: I used an AI coding assistant for this change, and I reviewed and verified everything submitted here.)

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

Add an uppercase hash option

1 participant