VOOZH about

URL: https://deepwiki.com/hypervel/hashing/1-introduction-to-hypervelhashing

⇱ hypervel/hashing | DeepWiki


Loading...
Menu

Introduction to Hypervel/Hashing

Purpose and Scope

The hypervel/hashing library provides password hashing capabilities for Hyperf framework applications. It implements a strategy pattern-based architecture supporting multiple hashing algorithms (Bcrypt, Argon2i, Argon2id) through a unified Hasher interface with configuration-driven driver selection.

This introduction covers the library's core components, dependencies, and integration model. For algorithm implementation details, see page 3. For framework integration specifics, see page 6. For usage examples, see page 5.

Sources: composer.json1-44

Library Overview

The hypervel/hashing library wraps PHP's password_hash(), password_verify(), and password_needs_rehash() functions within a framework-integrated abstraction. The HashManager class acts as a factory for algorithm-specific implementations (BcryptHasher, ArgonHasher, Argon2IdHasher), all conforming to the Hasher interface contract.

Key Capabilities

CapabilityImplementation
Algorithm SupportBcryptHasher, ArgonHasher, Argon2IdHasher classes
Driver FactoryHashManager with createBcryptDriver(), createArgonDriver(), createArgon2idDriver() methods
DI IntegrationConfigProvider registers Hasher::class and hash.driver bindings
Algorithm VerificationverifyAlgorithm option in concrete hasher classes
Configurationhashing.php config with driver, bcrypt, argon keys

Sources: composer.json1-44 System architecture diagrams (Diagram 1, 3)

Core Components Architecture

The library implements a factory pattern with the HashManager class creating algorithm-specific hashers. All implementations extend AbstractHasher and implement the Hasher interface.

Component Hierarchy


Sources: composer.json24-26 System architecture diagrams (Diagram 3, 5)

Framework Integration Model

The ConfigProvider class (composer.json39) registers the library with Hyperf's service container through the extra.hyperf.config composer.json property. The container resolves Hasher::class to HashManager instances.

Registration and Resolution Flow


Sources: composer.json38-39 System architecture diagrams (Diagram 2, 4)

Package Structure and Dependencies

The library follows Hyperf component conventions with PSR-4 autoloading and automatic service registration.

Namespace and Autoloading

PropertyValueReference
Package Namehypervel/hashingcomposer.json2
NamespaceHypervel\Hashing\composer.json25
Source Directorysrc/composer.json25
Typelibrarycomposer.json3

Runtime Requirements

DependencyVersion ConstraintPurpose
PHP^8.2Native password_* functions, type system
hyperf/config~3.1.0Access to config() helper and configuration loading
hyperf/context~3.1.0Request context management
hyperf/support~3.1.0Base Manager class, helper functions

Service Registration Mechanism

The ConfigProvider class (composer.json39) is auto-discovered through the extra.hyperf.config property and provides:

  • dependencies() method: Binds Hasher::class to HashManager factory
  • dependencies() method: Binds hash.driver to default driver instance
  • publish() method: Publishes publish/hashing.php to config/autoload/

Sources: composer.json1-44

Supported Hashing Algorithms

The library implements three industry-standard hashing algorithms, each with specific use cases and configuration options:

AlgorithmImplementation ClassPrimary Use CaseKey Features
BcryptBcryptHasherGeneral-purpose password hashingConfigurable rounds, broad compatibility
Argon2iArgonHasherMemory-hard hashing with side-channel resistanceMemory, time, and thread parameters
Argon2idArgon2IdHasherHybrid Argon2 with enhanced securityCombines Argon2i and Argon2d benefits

Each implementation extends AbstractHasher and implements the HasherContract interface, ensuring consistent behavior across all algorithms while allowing for algorithm-specific optimizations.

Sources: composer.json1-44 System architecture diagrams

This foundation enables applications to choose the most appropriate hashing algorithm for their security requirements while maintaining a consistent programming interface across all implementations.