h (hash) command calculates cryptographic hash values and checksums for files without archiving them.
Syntax
Description
The hash command:- Calculates checksums for file verification
- Supports multiple hash algorithms
- Can process multiple files and directories
- Generates hashes without compression
- Useful for integrity verification
- Can output in various formats
Supported Hash Algorithms
7-Zip supports several hash functions:CRC32
32-bit cyclic redundancy check
- Fast computation
- Good for error detection
- 8 character hex output
CRC64
64-bit cyclic redundancy check
- Better collision resistance than CRC32
- 16 character hex output
SHA256
256-bit secure hash
- Cryptographically secure
- Industry standard
- 64 character hex output
SHA1
160-bit secure hash (deprecated)
- Older standard
- Not recommended for security
- 40 character hex output
- BLAKE2sp - Fast cryptographic hash
- XXH64 - Extremely fast non-cryptographic hash
Common Options
Files or directories to hash. Supports wildcards.Example:
*.txt or documents/Set hash function to use. Options:
CRC32- 32-bit CRC (default)CRC64- 64-bit CRCSHA256- SHA-256 hashSHA1- SHA-1 hashXXH64- xxHash 64-bitBLAKE2SP- BLAKE2sp hash*- All available methods
-scrcSHA256Recurse subdirectories.
Include files matching pattern.Example:
-i!*.txtExclude files by pattern.Example:
-x!*.tmpStore hard links as links.
Store symbolic links as links.
Examples
Calculate CRC32 for a file
Calculate SHA256 hash
Calculate multiple hash types
Hash all files in directory
Hash with specific algorithm
Hash excluding certain files
Hash and redirect to file
Understanding Hash Output
Data Hash
Data and Names Hash
Multiple Files
Use Cases
File Integrity Verification
Create checksum file
Verify later
Download Verification
Duplicate Detection
Generate Checksums for Distribution
Advanced Examples
Hash with multiple algorithms
Recursive hash with pattern
Hash and sort by filename
Compare directory trees
Verify archive contents without extraction
Scripting Examples
Create and Verify Checksums
Monitor File Changes
Batch File Verification
Hash Algorithm Comparison
| Algorithm | Speed | Security | Output Size | Use Case |
|---|---|---|---|---|
| CRC32 | Fastest | None | 8 chars | Error detection |
| CRC64 | Very Fast | None | 16 chars | Error detection |
| XXH64 | Very Fast | None | 16 chars | Fast checksums |
| SHA1 | Fast | Weak | 40 chars | Legacy compatibility |
| SHA256 | Medium | Strong | 64 chars | Security, verification |
| BLAKE2SP | Fast | Strong | 64 chars | Modern alternative |
When to Use Each
CRC32/CRC64 - Quick integrity checks, non-security usePerformance Tips
- CRC is fastest - Use CRC32/CRC64 for speed
- SHA256 for security - Use when cryptographic security needed
- Batch processing - Hash multiple files in one command
- Exclude unnecessary files - Use
-xto skip temp files - Pipe for single file - Direct file to stdin for single hash
The “data and names” hash includes file paths in the calculation, making it useful for verifying both content and directory structure.
Integration Examples
With MD5SUM format (conversion)
Verify Against Published Hashes
Related Commands
- Test Command (t) - Test archive integrity
- Benchmark Command (b) - Performance testing
- Extract Command (x, e) - Extract and verify files