home / skills / aidotnet / moyucode / file-hasher

file-hasher skill

/skills/tools/file-hasher

This skill helps you compute cryptographic hashes for files to verify integrity, detect duplicates, and generate checksums.

npx playbooks add skill aidotnet/moyucode --skill file-hasher

Review the files below or copy the command above to add this skill to your agents.

Files (2)
SKILL.md
1007 B
---
name: file-hasher
description: 计算文件哈希值(MD5、SHA1、SHA256、SHA512)用于完整性验证和比较。
metadata:
  short-description: 计算文件哈希值
source:
  repository: https://github.com/python/cpython
  license: PSF
---

# File Hasher Tool

## Description
Calculate cryptographic hashes for files to verify integrity, detect duplicates, or generate checksums.

## Trigger
- `/hash` command
- User needs file checksums
- User wants to verify file integrity

## Usage

```bash
# Calculate SHA256 hash
python scripts/file_hasher.py file.zip

# Calculate multiple hash types
python scripts/file_hasher.py file.zip --all

# Verify against known hash
python scripts/file_hasher.py file.zip --verify abc123...

# Hash multiple files
python scripts/file_hasher.py *.zip --algorithm sha256

# Find duplicate files
python scripts/file_hasher.py --find-duplicates ./folder/
```

## Tags
`hash`, `checksum`, `md5`, `sha256`, `integrity`

## Compatibility
- Codex: ✅
- Claude Code: ✅

Overview

This skill calculates cryptographic hashes (MD5, SHA-1, SHA-256, SHA-512) for files to support integrity checks, duplicate detection, and checksum generation. It is designed for quick command-style use and scripted workflows. Results can be used to verify downloads, compare versions, or build reproducible validation steps.

How this skill works

The tool reads files in streaming mode and computes one or more hash digests without loading entire files into memory. It supports single-file hashing, multiple algorithms, batch processing (wildcards), verification against a provided hash, and duplicate discovery within a directory. Output is presented as plain checksum strings paired with filenames to make integration and parsing straightforward.

When to use it

  • Verify download integrity after transfer or mirror updates
  • Detect duplicate files across directories to reclaim space
  • Generate checksums for release artifacts or distribution packages
  • Automate integrity checks in CI/CD pipelines or nightly scans
  • Quickly compare local copies of large files without re-downloading

Best practices

  • Prefer SHA-256 or SHA-512 for security-sensitive integrity checks; use MD5/SHA-1 only for non-security duplicate detection
  • Stream files from disk or network mounts to avoid high memory use on large files
  • Store computed checksums alongside artifacts (e.g., .sha256 files) and sign them when distributing
  • Use the verify mode in automated scripts to fail builds on mismatch
  • When finding duplicates, confirm by file size and timestamps before deleting to avoid false positives

Example use cases

  • Compute SHA-256 for a release tarball before publishing to ensure clients can verify downloads
  • Run batch hashing (*.iso) to index checksums for backup archives
  • Verify a downloaded package against a known SHA-512 fingerprint before installation
  • Scan a media folder to find duplicate video files and generate a cleanup plan
  • Integrate a verify step in CI to compare build outputs with stored checksums

FAQ

Which algorithms are available?

MD5, SHA-1, SHA-256, and SHA-512 are supported; choose SHA-256 or SHA-512 for secure integrity checks.

Can I verify a file against a provided checksum?

Yes. A verify mode accepts a known hash string and returns match/mismatch so you can automate pass/fail logic.