Skip to content
hash-calculator logo

Hash Calculator

hash-calculator

Calculate cryptographic hashes (MD5, SHA1, SHA256, SHA512) for text and files. Compare hashes, verify integrity, and batch process directories.

SKILL.md

Full skill instructions

Hash Calculator

Calculate cryptographic hash values for text strings and files. Supports multiple algorithms, file verification, and batch processing.

Quick Start

from scripts.hash_calc import HashCalculator

# Hash text
calc = HashCalculator()
result = calc.hash_text("Hello, World!")
print(result['sha256'])

# Hash file
result = calc.hash_file("document.pdf")
print(result['md5'])

# Verify file integrity
is_valid = calc.verify_file("file.zip", "expected_hash", algorithm="sha256")

Features

  • Multiple Algorithms: MD5, SHA1, SHA256, SHA384, SHA512, BLAKE2
  • Text Hashing: Hash strings directly
  • File Hashing: Efficient streaming for large files
  • Verification: Compare against expected hash
  • Batch Processing: Hash multiple files
  • Checksum Files: Generate/​verify checksum files

API Reference

Text Hashing

calc = HashCalculator()

# Single algorithm
md5 = calc.hash_text("Hello", algorithm="md5")

# All algorithms
results = calc.hash_text("Hello")
# {'md5': '...', 'sha1': '...', 'sha256': '...', ...}

# Specific algorithms
results = calc.hash_text("Hello", algorithms=["md5", "sha256"])

File Hashing

# Single file
result = calc.hash_file("document.pdf")
print(result['sha256'])

# Specific algorithm
sha256 = calc.hash_file("file.zip", algorithm="sha256")

Verification

# Verify file against expected hash
is_valid = calc.verify_file(
    "download.iso",
    "a1b2c3d4e5...",
    algorithm="sha256"
)

# Verify text
is_valid = calc.verify_text("password", "5f4dcc3b...", algorithm="md5")

Batch Processing

# Hash all files in directory
results = calc.hash_directory("./​files", algorithm="sha256")
# {'file1.txt': 'abc...', 'file2.pdf': 'def...'}

# With recursive option
results = calc.hash_directory("./​files", recursive=True)

Checksum Files

# Generate checksum file
calc.generate_checksums("./​release", "checksums.sha256", algorithm="sha256")

# Verify against checksum file
results = calc.verify_checksums("checksums.sha256")
# {'file1.zip': True, 'file2.zip': True, 'file3.zip': False}

CLI Usage

# Hash text
python hash_calc.py --text "Hello, World!"

# Hash file
python hash_calc.py --file document.pdf

# Specific algorithm
python hash_calc.py --file document.pdf --algorithm sha256

# Verify file
python hash_calc.py --file download.iso --verify "expected_hash"

# Hash directory
python hash_calc.py --directory ./​files --output checksums.txt

# Verify checksums file
python hash_calc.py --verify-checksums checksums.sha256

CLI Arguments

ArgumentDescriptionDefault
--textText to hash-
--fileFile to hash-
--directoryDirectory to hash-
--algorithmHash algorithmall
--verifyExpected hash to verify-
--outputOutput file-
--recursiveRecursive directoryFalse
--verify-checksumsVerify checksum file-

Supported Algorithms

AlgorithmOutput LengthUse Case
md5128 bits (32 hex)Legacy, checksums (not secure)
sha1160 bits (40 hex)Legacy (not secure)
sha256256 bits (64 hex)General purpose, secure
sha384384 bits (96 hex)High security
sha512512 bits (128 hex)Maximum security
blake2b512 bitsModern, fast
blake2s256 bitsModern, fast, small

Examples

Verify Download Integrity

calc = HashCalculator()

# Downloaded file and expected hash from website
expected = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
is_valid = calc.verify_file("ubuntu.iso", expected, algorithm="sha256")

if is_valid:
    print("Download verified successfully!")
else:
    print("WARNING: Hash mismatch - file may be corrupted!")

Generate Release Checksums

calc = HashCalculator()

# Generate checksums for release files
calc.generate_checksums(
    "./​release",
    "SHA256SUMS",
    algorithm="sha256"
)

# Output: SHA256SUMS
# e3b0c44298fc1c14...  release-v1.0.zip
# a1b2c3d4e5f6g7h8...  release-v1.0.tar.gz

Password Storage (Example)

calc = HashCalculator()
import os

# Note: In production, use bcrypt/​argon2 instead
salt = os.urandom(16).hex()
password = "user_password"
hashed = calc.hash_text(salt + password, algorithm="sha256")

# Store: salt + ":" + hashed
stored = f"{salt}:{hashed}"

Compare Two Files

calc = HashCalculator()

hash1 = calc.hash_file("file1.txt", algorithm="sha256")
hash2 = calc.hash_file("file2.txt", algorithm="sha256")

if hash1 == hash2:
    print("Files are identical")
else:
    print("Files are different")

Output Formats

Text Output

MD5:    5d41402abc4b2a76b9719d911017c592
SHA1:   aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d
SHA256: 2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824

JSON Output

{
  "input": "hello",
  "md5": "5d41402abc4b2a76b9719d911017c592",
  "sha256": "2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824"
}

Dependencies

(No external dependencies - uses Python standard library)

Security Notes

  • MD5 and SHA1 are not collision-resistant (don't use for security)
  • Use SHA256 or higher for security applications
  • For password hashing, use dedicated libraries (bcrypt, argon2)
  • File hashing uses streaming to handle large files efficiently

More skills from majiayu000

xiaohongshu logo
majiayu000/claude-arsenal

xiaohongshu

xiaohongshu

286 148
View
agent-task-conductor logo
majiayu000/claude-skill-registry

agent-task-conductor

Conduct multi-agent task orchestration and workflow coordination.

663 1
View
conductor-setup logo
majiayu000/claude-skill-registry

conductor-setup

Initialize project with Conductor artifacts (product definition,

663 1
View
animation-designer logo
majiayu000/claude-skill-registry

animation-designer

Expert in web animations, transitions, and motion design using Framer Motion and CSS

663 1
View
diagramming logo
majiayu000/claude-skill-registry

diagramming

Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...

663 1
View
h3-pg logo
majiayu000/claude-skill-registry-data

h3-pg

PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.

23 1
View
conductor-development logo
majiayu000/claude-skill-registry

conductor-development

Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...

663 1
View
conductor-status logo
majiayu000/claude-skill-registry

conductor-status

Display project status, active tracks, and next actions

663 1
View
dockerization logo
majiayu000/claude-skill-registry

dockerization

Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.

663 1
View

Popular AI tools

Kaiber logo
Video

Kaiber

Generate, edit, and beat-sync AI video with leading models in one workspace.

Paid
View
Vimcal logo
Productivity

Vimcal

The world's fastest calendar for remote work

Free
View

Transform Your Design with AI Designer by ImgCreator.ai

Freemium
View
Akool AI logo
Content & writing

Akool AI

Revolutionizing Video Production with AI-Powered Creativity

Paid
View

Extend an image past the frame and let AI fill the new aspect ratio.

Freemium
View
StarByFace logo
Security

StarByFace

Discover your celebrity doppelgänger with StarByFace!

Free
View
C

ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.

Freemium
View
Opus Clip logo
Coding & apps

Opus Clip

Opus.ai: Revolutionize Your Web Experience

Free
View