stewbeet.plugins.compute_sha1

The compute_sha1 plugin generates SHA1 hashes for all generated zip archives.
It scans the output directory for zip files, computes their SHA1 checksums for integrity
verification, and creates a JSON file containing all hash values
for distribution verification, security auditing, and change detection purposes.

Feature Showcase

Example content of sha1_hashes.json

Position: Should run after all archive generation plugins
Optional: Multiple zip files in output directory (processes all found)
Related: Complements archive and merge_smithed_weld plugins
Source Code: stewbeet/plugins/compute_sha1/__init__.py

What it does

  • Computes SHA1 hashes for all generated zip archives
  • Creates a hash manifest for integrity verification
  • Enables change detection between builds
  • Provides security checksums for distribution verification
  • Scans output directory automatically for zip files
  • Generates machine-readable JSON hash file

Configuration

Basic Example Configuration

yaml
# No direct configuration required - uses project settings
# Requires output to be configured in beet.yml:
output: "build"

pipeline:
  - ...
  - stewbeet.plugins.compute_sha1

Configuration Options

OptionTypeDefaultDescription
outputstringRequiredDirectory containing zip files to hash
Hash AlgorithmconstantSHA1Uses SHA1 algorithm for checksum generation
Output Fileconstantsha1_hashes.jsonFilename for the generated hash manifest
File Filterautomatic*.zipOnly processes files with .zip extension

Features

Automatic Archive Discovery

Scans output directory for zip files to process:

  • πŸ“ Automatically discovers all zip files in the output directory
  • πŸ” Uses file extension filtering to identify archive files
  • πŸ“‹ Processes all found archives without manual configuration
  • βœ… Handles empty directories gracefully with no errors

SHA1 Hash Computation

Generates secure SHA1 checksums for each archive:

  • πŸ” Uses Python's built-in hashlib for reliable hash generation
  • πŸ“– Reads files in binary mode for accurate checksum calculation
  • 🎯 Generates standard hexadecimal hash representation
  • ⚑ Processes files efficiently with stream reading

Hash Manifest Creation

Creates a JSON file with all computed hashes:

  • πŸ“ Stores filename-to-hash mappings in JSON format
  • 🎨 Uses json_dump for properly formatted output
  • πŸ’Ύ Creates sha1_hashes.json file in the output directory
  • πŸ“Š Provides machine-readable format for automated verification

Integrity Verification System

Enables integrity checking and change detection:

  • βœ… Provides checksums for verifying archive integrity
  • πŸ” Enables detection of file corruption or tampering
  • πŸ“Š Supports automated verification workflows
  • πŸ”’ Creates audit trail for security compliance

Output Directory Integration

Integrates with beet's output directory system:

  • πŸ“‚ Uses configured output directory from project settings
  • βœ… Validates output directory existence before processing
  • 🎯 Works with any output directory configuration
  • πŸ”§ Integrates with beet's standard directory management

Efficient Processing Pipeline

Optimized for performance with minimal resource usage:

  • ⏱️ Uses measure_time decorator for performance monitoring
  • πŸ’Ύ Reads files once for hash calculation
  • πŸ“Š Processes all files in a single pass
  • 🧹 Clean and simple implementation with minimal overhead

Next steps